本文整理汇总了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(() => {});
}