mongodb#FindOneOptions TypeScript Examples
The following examples show how to use
mongodb#FindOneOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestApi.ts From majsoul-api with MIT License | 6 votes |
private findContest(contestId: string, options?: FindOneOptions): Promise<store.Contest<ObjectId>> {
return this.mongoStore.contestCollection.findOne(
{
$or: [
{ majsoulFriendlyId: parseInt(contestId) },
{ _id: ObjectId.isValid(contestId) ? ObjectId.createFromHexString(contestId) : null },
]
},
options ?? {
projection: {
'teams.image': false,
sessions: false,
}
}
);
}
Example #2
Source File: index.ts From integration-services with Apache License 2.0 | 5 votes |
static async getDocument<T>(collectionName: string, query: FilterQuery<T>, options?: WithoutProjection<FindOneOptions<T>>): Promise<T> {
const collection = MongoDbService.getCollection(collectionName);
return collection?.findOne(query, options);
}
Example #3
Source File: index.ts From integration-services with Apache License 2.0 | 5 votes |
static async getDocuments<T>(
collectionName: string,
query: FilterQuery<T>,
options?: WithoutProjection<FindOneOptions<T>>
): Promise<T[] | undefined> {
const collection = MongoDbService.getCollection(collectionName);
return collection?.find(query, options).toArray();
}