Limited arr length to 1
This commit is contained in:
parent
e12739b781
commit
cb6e84dab2
1
index.js
1
index.js
@ -1,7 +1,6 @@
|
||||
const express = require('express')
|
||||
const bodyParser = require('body-parser');
|
||||
const list = require("./listManager.js");
|
||||
const { response } = require('express');
|
||||
const app = express()
|
||||
|
||||
app.use(bodyParser.json(),function (req, res, next) {
|
||||
|
@ -48,13 +48,20 @@ list = {
|
||||
return await mongo.get("list","list",{"status": status})
|
||||
},
|
||||
getUser: async (username) => {
|
||||
return await mongo.get("list","list",{"user": username})
|
||||
res = await mongo.get("list","list",{"user": username})
|
||||
return res[0]
|
||||
},
|
||||
writeUser: async (obj) => {
|
||||
ver = await verifyMsg(obj)
|
||||
if (ver == true) {
|
||||
console.log(obj)
|
||||
mongo.put("list","list",obj)
|
||||
res = await mongo.get("list","list",{"user": obj.user})
|
||||
if (res.length > 0 ){
|
||||
mongo.update("list","list",{"user": obj.user}, obj)
|
||||
} else {
|
||||
mongo.put("list","list", obj)
|
||||
}
|
||||
mongo.update("list","list",{"user": obj.user}, obj)
|
||||
return {"Message":"Success"}
|
||||
} else {
|
||||
return ver
|
||||
|
Loading…
Reference in New Issue
Block a user