Update mongodb
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
Reference in New Issue
Block a user