mongodb#InsertOneResult TypeScript Examples
The following examples show how to use
mongodb#InsertOneResult.
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: user.ts From monkeytype with GNU General Public License v3.0 | 6 votes |
export async function addUser(
name: string,
email: string,
uid: string
): Promise<InsertOneResult<MonkeyTypes.User>> {
const user = await getUsersCollection().findOne({ uid });
if (user) {
throw new MonkeyError(409, "User document already exists", "addUser");
}
const currentDate = Date.now();
return await getUsersCollection().insertOne({
_id: new ObjectId(),
name,
email,
uid,
addedAt: currentDate,
});
}