mongodb-crud
This commit is contained in:
parent
4a74c31258
commit
a0d1437b2d
@ -3,14 +3,6 @@ import { Global } from "../models/Global";
|
||||
import { ReqAddPost, ResAddPost } from "../shared/protocols/PtlAddPost";
|
||||
|
||||
export async function ApiAddPost(call: ApiCall<ReqAddPost, ResAddPost>) {
|
||||
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: {
|
||||
|
@ -9,13 +9,15 @@ export async function ApiUpdatePost(call: ApiCall<ReqUpdatePost, ResUpdatePost>)
|
||||
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
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user