a simple and simulated database based on .json
npm i dbsim-db
const dbsimDb = require('dbsim-db');
you should create a .json with 'id_template' obj
like:
{
"id_template":{
"account":"",
"password":"",
"nick_name":"",
"age":0
}
}
dbsimDb.insert({
collection: 'user',
data: {
account: 'accountStr',
password: 'passwordStr',
nick_name: 'nickNameStr',
age: 10
}
});
dbsimDb.remove({
collection: 'user',
query: {
account: 'accountStr'
}
})
it also support regexp and double {} to query
it support or query
it support keys
it support limit
dbsimDb.find({
collection: 'user',
query: {
account: '/^\\w{4}$/',
$or: [{ age: '{{$>1}}' }, { nick_name: '/^nic/' }]
},
keys: ['account', 'nick_name'],
limit: 10
})
dbsimDb.update({
collection: 'user',
query: {
account: 'accountStr'
},
set: {
nick_name: 'anotherNickName'
},
mulit: false
})