InvoDB/demo/test.js

50 lines
776 B
JavaScript
Raw Normal View History

2021-11-25 00:24:39 +08:00
const invodb = require('..')
2021-11-13 23:15:21 +08:00
2021-11-25 00:24:39 +08:00
invodb.database('hr.invodb')
2021-11-13 23:15:21 +08:00
2021-11-25 00:24:39 +08:00
let person = invodb.collection('persons')
if(!person.exist()) person.create();
2021-11-12 15:58:21 +08:00
2021-11-25 00:24:39 +08:00
person.insert({
name: "张三",
age: 22,
salary: 3000,
kpi: 0.6
})
2021-11-12 15:58:21 +08:00
2021-11-25 00:24:39 +08:00
person.insert({
name: "李四",
age: 35,
salary: 6000,
kpi: 0.8
})
2021-11-12 15:58:21 +08:00
2021-11-25 00:24:39 +08:00
person.insert({
name: "王五",
age: 37,
salary: 20000,
kpi: 0.95
})
2021-11-22 19:11:18 +08:00
2021-11-25 00:24:39 +08:00
person.insert({
name: "李雷",
age: 32,
salary: 15000,
kpi: 0.35
})
2021-11-22 19:11:18 +08:00
2021-11-25 00:24:39 +08:00
console.log("优化互联网人力资源结构专项名单:")
let hr = person.query({
$or: [
{
age: { $gte: 35 },
salary: { $lt: 10000 }
},
{
kpi: { $lt: 0.4 },
salary: { $gte: 10000 }
2021-11-22 19:11:18 +08:00
}
2021-11-25 00:24:39 +08:00
]
})
2021-11-25 00:31:27 +08:00
console.log(hr)