mirror of
https://github.com/alwxkxk/soft-and-hard.git
synced 2025-01-28 06:32:54 +08:00
fix: id使用字符串。
This commit is contained in:
parent
7e864be92b
commit
fea9c89620
@ -14,20 +14,22 @@ let mongodb ={
|
||||
mongodb.insert = function(data,callback) {
|
||||
//添加插入时间
|
||||
data.createdAt= new Date()
|
||||
if(!dataObj[data.id]){
|
||||
dataObj[data.id] = []
|
||||
const id = String(data.id)
|
||||
if(!dataObj[id]){
|
||||
dataObj[id] = []
|
||||
}
|
||||
|
||||
dataObj[data.id].push(data)
|
||||
dataObj[id].push(data)
|
||||
// 超过10个的数据删除
|
||||
if(dataObj[data.id].length>10){
|
||||
dataObj[data.id].shift()
|
||||
if(dataObj[id].length>10){
|
||||
dataObj[id].shift()
|
||||
}
|
||||
}
|
||||
|
||||
// 查找数据
|
||||
mongodb.find=function (data,callback) {
|
||||
callback(null,dataObj[data.id] || []);
|
||||
const id = String(data.id)
|
||||
callback(null,dataObj[id] || []);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user