本文整理匯總了TypeScript中mongodb.Collection.count方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Collection.count方法的具體用法?TypeScript Collection.count怎麽用?TypeScript Collection.count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mongodb.Collection
的用法示例。
在下文中一共展示了Collection.count方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
observerRightNeighbour => {
Observable.fromPromise<number>(this.userCollection.count({})).subscribe(count => {
if (+registeredNumber < count - 1)
this.getDataFromRegisteredNumber(registeredNumber + 1).subscribe((rightNeighbour: User) => observerRightNeighbour.onNext(rightNeighbour));
else
observerRightNeighbour.onNext(null);
});
}
示例2:
readUser => {
if (readUser == null) {
Observable.fromPromise<number>(this.userCollection.count({})).subscribe(count => {
user.registeredNumber = count;
Observable.fromPromise<InsertOneWriteOpResult>(this.userCollection.insertOne(user)).subscribe(() => observer.onNext(true));
});
} else
observer.onNext(false);
}
示例3: contains
public async contains(id: string): Promise<boolean> {
const count = await this.collection.count({id: id});
return count > 0;
}