本文整理汇总了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;未经允许,请勿转载。 |
请发表评论