diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-16 11:38:09 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-16 11:38:09 +0900 |
| commit | 9427a756c9e4a1d95210ccfca56fdb67d62183ec (patch) | |
| tree | 667cf5f4d6ecf80d0e3a22c4085a410537d1dc9d /src/models/note.ts | |
| parent | fix(package): update @types/node to version 10.12.0 (#2912) (diff) | |
| download | sharkey-9427a756c9e4a1d95210ccfca56fdb67d62183ec.tar.gz sharkey-9427a756c9e4a1d95210ccfca56fdb67d62183ec.tar.bz2 sharkey-9427a756c9e4a1d95210ccfca56fdb67d62183ec.zip | |
Update mongodb
Diffstat (limited to 'src/models/note.ts')
| -rw-r--r-- | src/models/note.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/models/note.ts b/src/models/note.ts index e6bdbe0b8b..aeec075636 100644 --- a/src/models/note.ts +++ b/src/models/note.ts @@ -2,6 +2,7 @@ import * as mongo from 'mongodb'; const deepcopy = require('deepcopy'); import rap from '@prezzemolo/rap'; import db from '../db/mongodb'; +import isObjectId from '../misc/is-objectid'; import { length } from 'stringz'; import { IUser, pack as packUser } from './user'; import { pack as packApp } from './app'; @@ -107,7 +108,7 @@ export async function deleteNote(note: string | mongo.ObjectID | INote) { let n: INote; // Populate - if (mongo.ObjectID.prototype.isPrototypeOf(note)) { + if (isObjectId(note)) { n = await Note.findOne({ _id: note }); @@ -259,7 +260,7 @@ export const pack = async ( // Me const meId: mongo.ObjectID = me - ? mongo.ObjectID.prototype.isPrototypeOf(me) + ? isObjectId(me) ? me as mongo.ObjectID : typeof me === 'string' ? new mongo.ObjectID(me) @@ -269,7 +270,7 @@ export const pack = async ( let _note: any; // Populate the note if 'note' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(note)) { + if (isObjectId(note)) { _note = await Note.findOne({ _id: note }); |