diff --git a/ismism.ts/src/eid/db.ts b/ismism.ts/src/eid/db.ts index 80a9930..125c357 100644 --- a/ismism.ts/src/eid/db.ts +++ b/ismism.ts/src/eid/db.ts @@ -1,17 +1,59 @@ import { Collection, IndexOptions, MongoClient, UpdateFilter, Document } from "./mod.ts" import { Act, Agd, Aut, Dst, Lit, Ord, Soc, Usr, Video, Work, Wsl } from "./typ.ts" +export type Coll = Collection +export type Proj = Partial<{ [K in P]: 0 } | { [K in P]: 1 }> +export type Update = UpdateFilter +export type DocC<_Id> = Promise | null> +export type DocR = Promise | null> +export type DocU = Promise<0 | 1 | null> +export type DocD = Promise<0 | 1 | null> + const conn = new MongoClient() await conn.connect("mongodb://127.0.0.1:27017") export let coll = await db("tst", true) -export type Coll = Collection -export type Update = UpdateFilter -export type DocC<_Id> = Promise | null> -export type DocR = Promise | null> -export type DocU = Promise<0 | 1 | null> -export type DocD = Promise<0 | 1 | null> +export async function db( + dbnam: "ismism-dev" | "tst", + reset = false, +) { + const db = conn.database(dbnam) + const c = { + usr: db.collection("usr"), + agd: db.collection("agd"), + soc: db.collection("soc"), + + work: db.collection("work"), + video: db.collection