wabe-postgres 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ <p align="center">
2
+ <a href="https://wabe.dev"><img src="https://wabe.dev/assets/logo.png" alt="Wabe logo" height=170></a>
3
+ </p>
4
+
5
+ <div align="center">
6
+ <a href="https://wabe.dev">Documentation</a>
7
+ </div>
8
+
9
+ ## What is Wabe?
10
+
11
+ Wabe is an open-source backend as a service that allows you to create your own fully customizable backend in just a few minutes. It handles database access, automatic GraphQL API generation, authentication with various methods (classic or OAuth), permissions, security, and more for you.
12
+
13
+ ## Install for wabe-mongodb
14
+
15
+ ```sh
16
+ bun install wabe # On bun
17
+ npm install wabe # On npm
18
+ yarn add wabe # On yarn
19
+
20
+ bun install wabe-mongodb # On bun
21
+ npm install wabe-mongodb # On npm
22
+ yarn add wabe-mongodb # On yarn
23
+ ```
24
+
25
+ ## Basic example of wabe-mongodb usage
26
+
27
+ ```ts
28
+ import { Wabe } from "wabe";
29
+ import { MongoAdapter } from "wabe-mongodb";
30
+
31
+ const run = async () => {
32
+ // Ensure your database is running before run the file
33
+
34
+ const wabe = new Wabe({
35
+ isProduction: process.env.NODE_ENV === "production",
36
+ // Root key example (must be long minimal 64 characters, you can generate it online)
37
+ rootKey:
38
+ "0uwFvUxM$ceFuF1aEtTtZMa7DUN2NZudqgY5ve5W*QCyb58cwMj9JeoaV@d#%29v&aJzswuudVU1%nAT+rxS0Bh&OkgBYc0PH18*",
39
+ database: {
40
+ adapter: new MongoAdapter({
41
+ databaseName: "WabeApp",
42
+ databaseUrl: "mongodb://127.0.0.1:27045",
43
+ }),
44
+ },
45
+ port: 3001,
46
+ });
47
+
48
+ await wabe.start();
49
+ };
50
+
51
+ await run();
52
+ ```
package/bunfig.toml ADDED
@@ -0,0 +1,4 @@
1
+ telemetry = false
2
+
3
+ [test]
4
+ preload = ['./utils/preload.ts']
@@ -0,0 +1,74 @@
1
+ import { Pool } from "pg";
2
+ import { type AdapterOptions, type DatabaseAdapter, type GetObjectOptions, type CreateObjectOptions, type UpdateObjectOptions, type GetObjectsOptions, type CreateObjectsOptions, type UpdateObjectsOptions, type DeleteObjectsOptions, type WhereType, type DeleteObjectOptions, type OutputType, type CountOptions, type OrderType, type WabeTypes, type SchemaInterface } from "wabe";
3
+ export declare const buildPostgresOrderQuery: <
4
+ T extends WabeTypes,
5
+ K extends keyof T["types"],
6
+ U extends keyof T["types"][K]
7
+ >(order?: OrderType<T, K, U>) => string;
8
+ export declare const buildPostgresWhereQueryAndValues: <
9
+ T extends WabeTypes,
10
+ K extends keyof T["types"]
11
+ >(where?: WhereType<T, K>, startParamIndex?: number, parentKey?: string) => {
12
+ query: string;
13
+ values: any[];
14
+ paramIndex: number;
15
+ };
16
+ export declare class PostgresAdapter<T extends WabeTypes> implements DatabaseAdapter<T> {
17
+ options: AdapterOptions;
18
+ postgresPool: Pool;
19
+ pool: Pool;
20
+ constructor(options: AdapterOptions);
21
+ initializeDatabase(schema: SchemaInterface<T>);
22
+ clearDatabase();
23
+ close();
24
+ createClassIfNotExist(className: keyof T["types"], schema: SchemaInterface<T>);
25
+ count<K extends keyof T["types"]>(params: CountOptions<T, K>);
26
+ getObject<
27
+ K extends keyof T["types"],
28
+ U extends keyof T["types"][K]
29
+ >(params: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
30
+ getObjects<
31
+ K extends keyof T["types"],
32
+ U extends keyof T["types"][K],
33
+ W extends keyof T["types"][K]
34
+ >(params: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
35
+ createObject<
36
+ K extends keyof T["types"],
37
+ U extends keyof T["types"][K],
38
+ W extends keyof T["types"][K]
39
+ >(params: CreateObjectOptions<T, K, U, W>): Promise<{
40
+ id: string;
41
+ }>;
42
+ createObjects<
43
+ K extends keyof T["types"],
44
+ U extends keyof T["types"][K],
45
+ W extends keyof T["types"][K],
46
+ X extends keyof T["types"][K]
47
+ >(params: CreateObjectsOptions<T, K, U, W, X>): Promise<Array<{
48
+ id: string;
49
+ }>>;
50
+ updateObject<
51
+ K extends keyof T["types"],
52
+ U extends keyof T["types"][K],
53
+ W extends keyof T["types"][K]
54
+ >(params: UpdateObjectOptions<T, K, U, W>): Promise<{
55
+ id: string;
56
+ }>;
57
+ updateObjects<
58
+ K extends keyof T["types"],
59
+ U extends keyof T["types"][K],
60
+ W extends keyof T["types"][K],
61
+ X extends keyof T["types"][K]
62
+ >(params: UpdateObjectsOptions<T, K, U, W, X>): Promise<Array<{
63
+ id: string;
64
+ }>>;
65
+ deleteObject<
66
+ K extends keyof T["types"],
67
+ U extends keyof T["types"][K]
68
+ >(params: DeleteObjectOptions<T, K, U>): Promise<void>;
69
+ deleteObjects<
70
+ K extends keyof T["types"],
71
+ U extends keyof T["types"][K],
72
+ W extends keyof T["types"][K]
73
+ >(params: DeleteObjectsOptions<T, K, U, W>): Promise<void>;
74
+ }