wabe-mongodb 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 +52 -0
- package/bunfig.toml +4 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +66341 -0
- package/package.json +39 -0
- package/utils/preload.ts +8 -0
- package/utils/testHelper.ts +121 -0
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
|
+
url: "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
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type Db, MongoClient } from "mongodb";
|
|
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 buildMongoOrderQuery: <
|
|
4
|
+
T extends WabeTypes,
|
|
5
|
+
K extends keyof T["types"],
|
|
6
|
+
U extends keyof T["types"][K]
|
|
7
|
+
>(order?: OrderType<T, K, U>) => Record<string, any>;
|
|
8
|
+
export declare const buildMongoWhereQuery: <
|
|
9
|
+
T extends WabeTypes,
|
|
10
|
+
K extends keyof T["types"]
|
|
11
|
+
>(where?: WhereType<T, K>) => Record<string, any>;
|
|
12
|
+
export declare class MongoAdapter<T extends WabeTypes> implements DatabaseAdapter<T> {
|
|
13
|
+
options: AdapterOptions;
|
|
14
|
+
database?: Db;
|
|
15
|
+
client: MongoClient;
|
|
16
|
+
constructor(options: AdapterOptions);
|
|
17
|
+
close();
|
|
18
|
+
createClassIfNotExist(className: keyof T["types"], schema: SchemaInterface<T>);
|
|
19
|
+
initializeDatabase(schema: SchemaInterface<T>): Promise<void>;
|
|
20
|
+
clearDatabase();
|
|
21
|
+
count<K extends keyof T["types"]>(params: CountOptions<T, K>);
|
|
22
|
+
getObject<
|
|
23
|
+
K extends keyof T["types"],
|
|
24
|
+
U extends keyof T["types"][K]
|
|
25
|
+
>(params: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
|
|
26
|
+
getObjects<
|
|
27
|
+
K extends keyof T["types"],
|
|
28
|
+
U extends keyof T["types"][K],
|
|
29
|
+
W extends keyof T["types"][K]
|
|
30
|
+
>(params: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
|
|
31
|
+
createObject<
|
|
32
|
+
K extends keyof T["types"],
|
|
33
|
+
U extends keyof T["types"][K],
|
|
34
|
+
W extends keyof T["types"][K]
|
|
35
|
+
>(params: CreateObjectOptions<T, K, U, W>);
|
|
36
|
+
createObjects<
|
|
37
|
+
K extends keyof T["types"],
|
|
38
|
+
U extends keyof T["types"][K],
|
|
39
|
+
W extends keyof T["types"][K],
|
|
40
|
+
X extends keyof T["types"][K]
|
|
41
|
+
>(params: CreateObjectsOptions<T, K, U, W, X>);
|
|
42
|
+
updateObject<
|
|
43
|
+
K extends keyof T["types"],
|
|
44
|
+
U extends keyof T["types"][K],
|
|
45
|
+
W extends keyof T["types"][K]
|
|
46
|
+
>(params: UpdateObjectOptions<T, K, U, W>);
|
|
47
|
+
updateObjects<
|
|
48
|
+
K extends keyof T["types"],
|
|
49
|
+
U extends keyof T["types"][K],
|
|
50
|
+
W extends keyof T["types"][K],
|
|
51
|
+
X extends keyof T["types"][K]
|
|
52
|
+
>(params: UpdateObjectsOptions<T, K, U, W, X>);
|
|
53
|
+
deleteObject<
|
|
54
|
+
K extends keyof T["types"],
|
|
55
|
+
U extends keyof T["types"][K]
|
|
56
|
+
>(params: DeleteObjectOptions<T, K, U>);
|
|
57
|
+
deleteObjects<
|
|
58
|
+
K extends keyof T["types"],
|
|
59
|
+
U extends keyof T["types"][K],
|
|
60
|
+
W extends keyof T["types"][K]
|
|
61
|
+
>(params: DeleteObjectsOptions<T, K, U, W>);
|
|
62
|
+
}
|