mongodb#WithId TypeScript Examples
The following examples show how to use
mongodb#WithId.
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: index.ts From integration-services with Apache License 2.0 | 6 votes |
static async insertDocument<T>(
collectionName: string,
data: any,
options?: CollectionInsertOneOptions
): Promise<InsertOneWriteOpResult<WithId<T>> | undefined> {
const ommitedData: any = _.omitBy(data, _.isUndefined);
const collection = MongoDbService.getCollection(collectionName);
return collection?.insertOne(ommitedData, options);
}
Example #2
Source File: setup-tests.ts From monkeytype with GNU General Public License v3.0 | 5 votes |
jest.mock("./src/init/db", () => ({
__esModule: true,
getDb: (): Db => db,
collection: <T>(name: string): Collection<WithId<T>> =>
db.collection<WithId<T>>(name),
}));
Example #3
Source File: user.ts From monkeytype with GNU General Public License v3.0 | 5 votes |
getUsersCollection = (): Collection<WithId<MonkeyTypes.User>> =>
db.collection<MonkeyTypes.User>("users")
Example #4
Source File: db.ts From monkeytype with GNU General Public License v3.0 | 5 votes |
export function collection<T>(collectionName: string): Collection<WithId<T>> {
if (!db) {
throw new MonkeyError(500, "Database is not initialized.");
}
return db.collection<WithId<T>>(collectionName);
}