dbsim-db

1.0.2 • Public • Published

dbsim-db

a simple and simulated database based on .json

install

npm i dbsim-db

use module

const dbsimDb = require('dbsim-db');

database json

you should create a .json with 'id_template' obj
like:

{
    "id_template":{
        "account":"",
        "password":"",
        "nick_name":"",
        "age":0
    }
}

use dbsimDb

insert sample

dbsimDb.insert({
    collection: 'user',
    data: {
        account: 'accountStr',
        password: 'passwordStr',
        nick_name: 'nickNameStr',
        age: 10
    }
});

delete sample

dbsimDb.remove({
    collection: 'user',
    query: {
        account: 'accountStr'
    }
})

find sample

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
})

update sample

dbsimDb.update({
    collection: 'user',
    query: {
        account: 'accountStr'
    },
    set: {
        nick_name: 'anotherNickName'
    },
    mulit: false
})

Readme

Keywords

Package Sidebar

Install

npm i dbsim-db

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

9.05 kB

Total Files

4

Last publish

Collaborators

  • ccbbs