download data record

This commit is contained in:
CPunisher 2020-05-08 16:08:17 +08:00
parent f235315bc3
commit 5dc5c80460
1 changed files with 18 additions and 13 deletions

View File

@ -17,21 +17,26 @@ 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({ counter.where({
value: _.eq(value) value: _.eq(value)
}).update({ }).get().then(res => {
count: _.inc(1) if (res.data.length > 0) {
}).then(res => { counter.where({
console.log(res) value: _.eq(value)
}).update({
count: _.inc(1)
}).then(res => {
console.log(res)
})
}
else {
counter.add({
value: value,
count: 1
}).then(res => {
console.log(res)
})
}
}) })
} }