Simplify the use of mongodb with typescript, Without db.collection("your collection").findOne()
const db = await snoMongoKu(mongo_connect_url);
await db.myAnyCollection.findOne({ a: 1 }); // Magic!
// it is just same as
// await mongoClient.db(...).collection("your collection").findOne()
await db.myAnyCollection.upsertMany(
[
{ email: "snomiao@gmail.com", name: "snomiao" },
{ email: "example@example.com", name: "example" },
],
{ email: 1 },
); // Upsert many with index!
await db.myAnyCollection.upsertMany([
{ _id: "n9MidAL5SGhpm1jf", email: "snomiao@gmail.com", name: "snomiao" },
{ _id: "n9MidAL5SGhpm1jf", email: "example@example.com", name: "example" },
]); // Upsert many with _id.
GPLv3 - The GNU General Public License v3.0 - GNU Project - Free Software Foundation
Author: snomiao snomiao@gmail.com Website: snomiao.com
- None yet.
Claim your sponsorship by donating snomiao <Email: snomiao@gmail.com>
The main repo is in here, any issue and PR's welcome.