This commit is contained in:
ciaochaos 2020-05-08 16:43:00 +08:00
commit 0c87fbc129
1 changed files with 18 additions and 13 deletions

View File

@ -17,16 +17,11 @@ const db = app.database();
const _ = db.command const _ = db.command
const counter = db.collection('QRCounter'); const counter = db.collection('QRCounter');
export function insert(value) {
counter.add({
value: value,
count: 1
}).then(res => {
console.log(res);
})
}
export function update(value) { export function update(value) {
counter.where({
value: _.eq(value)
}).get().then(res => {
if (res.data.length > 0) {
counter.where({ counter.where({
value: _.eq(value) value: _.eq(value)
}).update({ }).update({
@ -35,3 +30,13 @@ export function update(value) {
console.log(res) console.log(res)
}) })
} }
else {
counter.add({
value: value,
count: 1
}).then(res => {
console.log(res)
})
}
})
}