UNPKG

prostgles-types

Version:

Shared TypeScript object definitions for prostgles-client and prostgles-server

147 lines 4.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Type tests */ async () => { const r = 1; const sel1 = { id: 1, name: 1, public: 1, $rowhash: 1, added_day: { $day: [] } }; const sel2 = { id: 1, name: 1, public: 1, $rowhash: 1, dsds: { d: [] }, }; const sel3 = ""; const sel4 = "*"; const sel12 = { id: 1, name: 1, public: 1, $rowhash: 1, dsds: { d: [] } }; const sel13 = ""; const sel14 = "*"; const fRow = { $rowhash: { $in: [""] }, }; const emptyFilter = {}; const sel32 = { dwa: 1, }; const sel = { a: 1, $rowhash: 1, dwadwA: { dwdwa: [5] }, }; const sds = sel; const sds01 = ""; const sds02 = "*"; const sds03 = {}; const sds2 = sel; const s001 = { h: { $ts_headline_simple: ["name", { plainto_tsquery: "abc81" }] }, hh: { $ts_headline: ["name", "abc81"] }, added: "$date_trunc_2hour", addedY: { $date_trunc_5minute: ["added"] }, }; //@ts-expect-error const badSel = { a: 1, b: 0, }; //@ts-expect-error const badSel1 = { b: 1, a: 1, }; const sds3 = { // "*": 1, // a: "$funcName", a: { dwda: [] }, $rowhashD: { dwda: [] }, // dwadwa: 1, //{ dwa: []} }; const sel1d = { dwada: 1, $rowhash: 1, dwawd: { funcName: [12] }, }; const sel1d2 = ["a"]; const deletePar = { returning: { id: 1, name: 1, public: 1, $rowhash: 1, added_day: { $day: ["added"] } }, }; }; /** More Type tests */ async () => { const tableHandler = undefined; tableHandler.insert({ h: 1, c: 2, "b.$func": { dwa: [] } }); const schemaFFilter = { "col1.$eq": "dd" }; const fullFilter = schemaFFilter; const ffFunc = (f) => { }; ffFunc(schemaFFilter); const dbo = 1; const funcData = { funcName: [] }; const noRow = await dbo.tbl1.update({}, { col1: "" }); //@ts-expect-error noRow.length; //@ts-expect-error noRow.col1; const someData = await dbo.tbl1.find({}, { select: { col1: 1 }, orderBy: { col1: -1 } }); const noRowFunc = await dbo.tbl1.update({}, { col1: "" }); const oneRow = await dbo.tbl1.update({}, { col1: "" }, { returning: "*", multi: false }); //@ts-expect-error oneRow?.length; //@ts-expect-error oneRow.col1; oneRow?.col1; const manyRows = await dbo.tbl1.update({}, { col1: "" }, { returning: "*" }); //@ts-expect-error manyRows?.col1; manyRows?.at(0)?.col1; const noIRow = await dbo.tbl1.insert({ col1: "", col2: { $func: [] } }); //@ts-expect-error noIRow.length; //@ts-expect-error noIRow.col1; const irow = await dbo.tbl1.insert({ col1: "", col2: funcData }, { returning: "*" }); //@ts-expect-error irow.length; irow.col1; const irowFunc = await dbo.tbl1.insert({ col1: funcData, col2: "" }, { returning: "*" }); const irows = await dbo.tbl1.insert([{ col1: "", col2: "" }], { returning: "*" }); //@ts-expect-error irows.col1; irows.length; const filter = {}; const filterCheck = (f) => { }; filterCheck(filter); const t = {}; const d = t; const fup = (a) => { }; fup(t); // const f = <A extends TableHandler["count"]>(a: A) => {}; const f = (s) => { }; const th = {}; // f(th) const sp = { select: {} }; const sf = (sp) => { }; sf(sp); // const sub: TableHandler["count"] = dbo.tbl1.count /** * Upsert data funcs */ const gdw = { a: { dwa: [] }, z: { dwa: [] }, }; const gdwn = { a: 2, z: { dwa: [] }, }; const gdw1 = { a: 1, z: 2 }; const gdw1Opt = { a: {}, z: 2 }; const gdw2 = { a: { dwa: [] }, z: { dwa: [] } }; //@ts-expect-error const missingKey = { z: 1, z: { dwa: [] } }; //@ts-expect-error const missingKey2 = { z: 1 }; // ra(schema); }; //# sourceMappingURL=typeTests.js.map