InvoDB/demo/test.js

26 lines
506 B
JavaScript
Raw Normal View History

2021-11-13 23:15:21 +08:00
const fs = require('fs')
2021-11-12 15:58:21 +08:00
const invodb = require('..')
invodb.database('zzz.invodb')
2021-11-22 19:11:18 +08:00
let col = invodb.collection('blog')
2021-11-12 15:58:21 +08:00
if(!col.exist()) col.create();
2021-11-22 19:11:18 +08:00
for(let json of col.query({})) col.remove(json)
let list = fs.readFileSync(__dirname + "/list.txt").toString().split("\n")
for(let json of list) {
col.insert(JSON.parse(json))
}
let result = col.query(
{
"title": {
"$gte": "数据库设计(1)",
"$lte": "数据库设计(5)",
}
}
)
console.log(result)