當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mongoose.Types類代碼示例

本文整理匯總了TypeScript中mongoose.Types的典型用法代碼示例。如果您正苦於以下問題:TypeScript Types類的具體用法?TypeScript Types怎麽用?TypeScript Types使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Types類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

Account.statics.verifyAccount = function(verificationCode: string, cb) {
    //console.log("inside verify account:" + verificationCode);
    this.findOne({
        'verificationCode': mongoose.Types.ObjectId(verificationCode)
    },
        'username',
        (err, user) => {
            if (user != null) {
                //console.log("User with verificationCode: " + verificationCode);
                if (err) {
                    //console.log("findUserByVerficationCode: " + err);
                    cb(err, null);
                };
                user.verificationCode = null;
                user.isVerified = true;
                user.save(function(saveErr) {
                    if (saveErr) {
                        return cb(saveErr);
                    }
                    cb(null, user);
                });
            }else{
                cb({error: 'Invalid verification code or verification code no longer valid.'}, null);
            }
        });
}
開發者ID:sumitkm,項目名稱:sumitmaitra.com,代碼行數:26,代碼來源:account.ts

示例2: DislikeComentario

export function DislikeComentario(req: express.Request, res: express.Response, next: NextFunction) {
    Comentario.findOneAndUpdate({_id: mongoose.Types.ObjectId(req.params.id)}, {$inc : {"dislike" : 1}}).exec(function(err, comentario) {
        if (err) return errorHandler.handleError(res, err);
        res.json(comentario);
    });

}
開發者ID:maticorv,項目名稱:mascotas2018_foro,代碼行數:7,代碼來源:comentario.service.ts

示例3: getOneTema

 export function getOneTema(req: express.Request, res: express.Response, next: NextFunction) {
   const tema_id = mongoose.Types.ObjectId(req.params.tema_id);
   Tema.findOne({_id: tema_id}).exec(function (err, tema) {
     if (err) return next();
     res.json(tema);
   });
 }
開發者ID:maticorv,項目名稱:mascotas2018_foro,代碼行數:7,代碼來源:foro.service.ts

示例4:

		const results = await Promise.all(users.map(user => {
			return Channel.update({
				user_id: mongoose.Types.ObjectId(user._id.$oid),
				type: CHANNEL_TYPE_MAIN
			}, {profileImg: user.profileImg});
			//
			// return Channel.findOneAndUpdate(
			// 	{
			// 		user_id: mongoose.Types.ObjectId(user._id.$oid),
			// 		type: CHANNEL_TYPE_MAIN
			// 	}, {
			// 		user_id: mongoose.Types.ObjectId(user._id.$oid),
			// 		name: user.username,
			// 		profileImg: user.profileImg
			// 	},
			// 	{
			// 		upsert: true,
			// 		new: true,
			// 		setDefaultsOnInsert: true
			// 	},
			// 	(err, res) => {
			// 		console.log('err', err);
			// 		console.log('res', res);
			// 		// Deal with the response data/error
			// 	});
		}));
開發者ID:Chegeek,項目名稱:TradeJS,代碼行數:26,代碼來源:mongo.ts

示例5: function

const decline: TDeclineFunc = async function(this: IFriendshipDocument, declinedUserId) {
  if (!this.accepted) {
    if (!this.senderId.equals(declinedUserId)) {
      throw new WrongUserDeclineFriendshipError();
    }

    await this.remove();
    return null;
  }

  if (!this.senderId.equals(declinedUserId) && !this.receiverId.equals(declinedUserId)) {
    throw new WrongUserDeclineFriendshipError();
  }

  if (this.receiverId.equals(declinedUserId)) {
    this.accepted = false;
    await this.save();

    return this;
  }

  this.senderId = this.receiverId;
  this.receiverId = mongoose.Types.ObjectId(declinedUserId);
  this.accepted = false;

  await this.save();

  return this;
};
開發者ID:dmikheev,項目名稱:js-test-social-network,代碼行數:29,代碼來源:friendship.ts

示例6: getCurrentPost

export function getCurrentPost(req: express.Request, res: express.Response, next: NextFunction) {
    console.log("ID: " + req.params.postid);
    Post.findOne({_id: mongoose.Types.ObjectId(req.params.postid)}).exec(function(error, post) {
        if (error) {
            return next(); }
        res.json(post);
    });
}
開發者ID:maticorv,項目名稱:mascotas2018_foro,代碼行數:8,代碼來源:post.service.ts

示例7: function

app.get('/booking', function (req, res) {
    Booking.find({ userID: mongoose.Types.ObjectId("53b81a2f034eb5db75ec16ad")}, function (err, booking:any[]) {
        if (err) return console.log(err);
        res.send(booking);
    });

    console.log('get booking',req.body);
});
開發者ID:graetzer,項目名稱:fly2moon,代碼行數:8,代碼來源:server.ts

示例8: deletePost

export function deletePost(req: express.Request, res: express.Response, next: NextFunction ) {
    Post.deleteOne({_id:  mongoose.Types.ObjectId(req.params.postid) }).exec(function(error, post) {
        if (error) return next();
        return res.json(post);
    });
}
開發者ID:maticorv,項目名稱:mascotas2018_foro,代碼行數:6,代碼來源:post.service.ts


注:本文中的mongoose.Types類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。