本文整理匯總了TypeScript中then-mongo.Collection類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Collection類的具體用法?TypeScript Collection怎麽用?TypeScript Collection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Collection類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: addContent
addContent(content: dbContent): Promise<void> {
return this.contents.insert(content, {safe: true}).then<void, void>(
() => {},
err => {
if (err.code != 11000) {
//if not "document already exists"
throw err;
}
},
);
}
示例2: addHeader
addHeader(header: dbHeader): Promise<void> {
return this.headers.insert(header, {safe: true}).then<void, void>(
() => {},
err => {
if (err.code != 11000) {
//if not "document already exists"
throw err;
}
},
);
}
示例3: logRun
logRun(start: Date, end: Date): Promise<void> {
var now = new Date();
var day = now.toISOString().split('T')[0];
return Promise.all([
this.log.insert(
{
type: 'bot-run',
start,
end,
},
{safe: true},
),
this.runsPerDay.update(
{_id: day},
{
$inc: {
runs: 1,
totalDuration: start.getTime() - end.getTime(),
},
},
{upsert: true},
),
]).then(() => {});
}
示例4: hasContent
hasContent(id: string): Promise<boolean> {
return this.headers
.find({_id: id})
.count()
.then(result => !!result);
}
示例5: getHeaderByUrl
getHeaderByUrl(url: string): Promise<dbHeader> {
return this.headers.findOne({url: url}) as any;
}
示例6: updateTopic
updateTopic(topic: dbTopic): Promise<void> {
return this.topics
.update({_id: topic._id}, topic, {upsert: true})
.then(() => {});
}