From a0d1437b2deb5bb2393959d37f6902f47bff54bb Mon Sep 17 00:00:00 2001 From: King Wang Date: Sun, 27 Jun 2021 01:56:15 +0800 Subject: [PATCH] mongodb-crud --- examples/mongodb-crud/backend/src/api/ApiAddPost.ts | 8 -------- .../mongodb-crud/backend/src/api/ApiUpdatePost.ts | 12 +++++++----- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/examples/mongodb-crud/backend/src/api/ApiAddPost.ts b/examples/mongodb-crud/backend/src/api/ApiAddPost.ts index 924a185..3491e1a 100644 --- a/examples/mongodb-crud/backend/src/api/ApiAddPost.ts +++ b/examples/mongodb-crud/backend/src/api/ApiAddPost.ts @@ -3,14 +3,6 @@ import { Global } from "../models/Global"; import { ReqAddPost, ResAddPost } from "../shared/protocols/PtlAddPost"; export async function ApiAddPost(call: ApiCall) { - console.log('cccgasdgasd', call.service.conf) - if (call.service.conf) { - // if (没登录) { - // call.error('你还没登录'); - // return; - // } - } - let op = await Global.collection('Post').insertOne({ ...call.req.newPost, create: { diff --git a/examples/mongodb-crud/backend/src/api/ApiUpdatePost.ts b/examples/mongodb-crud/backend/src/api/ApiUpdatePost.ts index 24c8605..4cddbaa 100644 --- a/examples/mongodb-crud/backend/src/api/ApiUpdatePost.ts +++ b/examples/mongodb-crud/backend/src/api/ApiUpdatePost.ts @@ -9,13 +9,15 @@ export async function ApiUpdatePost(call: ApiCall) let op = await Global.collection('Post').updateOne({ _id: new ObjectID(_id) }, { - $set: update + $set: { + ...update, + update: { + uid: 'xxx', + time: new Date() + } + } }); - console.log('ssss', { - matchedCount: op.matchedCount - }) - call.succ({ matchedCount: op.matchedCount })