fluxor-cloud-db 1.0.0

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.
@@ -0,0 +1,8 @@
1
+
2
+
3
+ export type DynamoConfig = {
4
+ region: string,
5
+ endpoint: string,
6
+ accessKeyId?: string
7
+ secretAccessKey?: string
8
+ }
@@ -0,0 +1,71 @@
1
+ import { WhereClause } from "./types/query";
2
+
3
+ interface Condition {
4
+ operator: string;
5
+ value: unknown;
6
+ }
7
+
8
+ // ── Equality ──────────────────────────────────────────────────────────────────
9
+
10
+ export const eq = (value: unknown): Condition =>
11
+ ({ operator: "=", value });
12
+
13
+ export const neq = (value: unknown): Condition =>
14
+ ({ operator: "!=", value });
15
+
16
+ // ── Comparison ────────────────────────────────────────────────────────────────
17
+
18
+ export const gt = (value: number | string): Condition =>
19
+ ({ operator: ">", value });
20
+
21
+ export const gte = (value: number | string): Condition =>
22
+ ({ operator: ">=", value });
23
+
24
+ export const lt = (value: number | string): Condition =>
25
+ ({ operator: "<", value });
26
+
27
+ export const lte = (value: number | string): Condition =>
28
+ ({ operator: "<=", value });
29
+
30
+ // ── Range ─────────────────────────────────────────────────────────────────────
31
+
32
+ /** Inclusive range. MongoDB only. */
33
+ export const between = (min: number | string, max: number | string): Condition =>
34
+ ({ operator: "BETWEEN", value: [min, max] });
35
+
36
+ // ── List ──────────────────────────────────────────────────────────────────────
37
+
38
+ export const anyOf = (values: unknown[]): Condition =>
39
+ ({ operator: "IN", value: values });
40
+
41
+ export const noneOf = (values: unknown[]): Condition =>
42
+ ({ operator: "NOT_IN", value: values });
43
+
44
+ // ── String ────────────────────────────────────────────────────────────────────
45
+
46
+ export const startsWith = (value: string): Condition =>
47
+ ({ operator: "BEGINS_WITH", value });
48
+
49
+ /** Case-insensitive substring match. MongoDB only. */
50
+ export const like = (value: string): Condition =>
51
+ ({ operator: "LIKE", value });
52
+
53
+ // ── Existence ─────────────────────────────────────────────────────────────────
54
+
55
+ /** Field presence check. MongoDB only. */
56
+ export const exists = (value = true): Condition =>
57
+ ({ operator: "EXISTS", value });
58
+
59
+ // ── Convenience re-exports ────────────────────────────────────────────────────
60
+
61
+ /** Alias for eq */
62
+ export const equals = eq;
63
+
64
+ /** Alias for neq */
65
+ export const notEquals = neq;
66
+
67
+ /** Alias for anyOf */
68
+ export const inList = anyOf;
69
+
70
+ /** Alias for noneOf */
71
+ export const notInList = noneOf;
package/src/index.ts ADDED
@@ -0,0 +1,39 @@
1
+ import { resolveService } from "fluxor-cloud";
2
+
3
+ import { DynamoService } from "./dynamo/dynamo";
4
+ import { MongoService } from "./mongo/mongo";
5
+
6
+ /**
7
+ * Resolves the {@link DynamoService} instance from the service container.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const dynamo = useDynamo();
12
+ * const user = await dynamo.selectOne("users", { id: { operator: "=", value: 1 } });
13
+ * ```
14
+ *
15
+ * @returns The registered {@link DynamoService} instance.
16
+ */
17
+ export const useDynamo = (): DynamoService => {
18
+ return resolveService(DynamoService);
19
+ }
20
+
21
+ /**
22
+ * Resolves the {@link MongoService} instance from the service container.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const mongo = useMongo();
27
+ * const users = await mongo.selectMany("users", { status: { operator: "=", value: "active" } });
28
+ * ```
29
+ *
30
+ * @returns The registered {@link MongoService} instance.
31
+ */
32
+ export const useMongo = (): MongoService => {
33
+ return resolveService(MongoService);
34
+ }
35
+
36
+ export * from './dynamo/dynamo';
37
+ export * from './dynamo/dynamo.types'
38
+ export * from './mongo/mongo';
39
+ export * from './fluentapi'