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 express = require('express')
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
const list = require("./listManager.js");
|
const list = require("./listManager.js");
|
||||||
const { response } = require('express');
|
|
||||||
const app = express()
|
const app = express()
|
||||||
|
|
||||||
app.use(bodyParser.json(),function (req, res, next) {
|
app.use(bodyParser.json(),function (req, res, next) {
|
||||||
|
@ -48,13 +48,20 @@ list = {
|
|||||||
return await mongo.get("list","list",{"status": status})
|
return await mongo.get("list","list",{"status": status})
|
||||||
},
|
},
|
||||||
getUser: async (username) => {
|
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) => {
|
writeUser: async (obj) => {
|
||||||
ver = await verifyMsg(obj)
|
ver = await verifyMsg(obj)
|
||||||
if (ver == true) {
|
if (ver == true) {
|
||||||
console.log(obj)
|
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"}
|
return {"Message":"Success"}
|
||||||
} else {
|
} else {
|
||||||
return ver
|
return ver
|
||||||
|
Loading…
Reference in New Issue
Block a user