const db = await new DB({
collection: [
{ name: 'test' }
]
}).init()
new DB({
root: path.resolve() // the db file root path
default: '{ "rows": [] }', // db file default value, you can set default data in "rows",
collection: [ // db file list
{
name: 'test', // db name
schema, // json schema, add this to validate data when insert or update,
physicalDeletion: false, // when remove data, if set physicalDeletion true, will remove data in json, but set false, just set "isDelete" true in data
}
]
})
db.test.insert({
id: 1,
text: 2333
})
db.test.insertMany([
{
id: 2,
text: 666
},
{
id: 3,
text: 666
}
])
db.test.findAll({ text: 666 })
db.test.remove({ id: 1 })
db.test.removeAll({ text: 666 })
db.test.update({ id: 3 })
db.test.updateAll({ text: 666 })