@rebasepro/common 0.1.2 → 0.2.3
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/LICENSE +1 -1
- package/dist/data/query_builder.d.ts +51 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +396 -188
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +395 -187
- package/dist/index.umd.js.map +1 -1
- package/dist/util/entities.d.ts +2 -2
- package/dist/util/relations.d.ts +1 -1
- package/package.json +16 -15
- package/src/collections/CollectionRegistry.ts +24 -37
- package/src/data/buildRebaseData.ts +25 -5
- package/src/data/query_builder.ts +117 -0
- package/src/index.ts +2 -0
- package/src/types/json-logic-js.d.ts +1 -1
- package/src/util/builders.ts +1 -0
- package/src/util/entities.ts +6 -2
- package/src/util/relations.ts +83 -22
- package/src/util/resolutions.ts +6 -3
package/LICENSE
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FindResponse, CollectionAccessor, QueryBuilderInterface, FilterOperator } from "@rebasepro/types";
|
|
2
|
+
export declare class QueryBuilder<M extends Record<string, unknown> = Record<string, unknown>> implements QueryBuilderInterface<M> {
|
|
3
|
+
private collection;
|
|
4
|
+
private params;
|
|
5
|
+
constructor(collection: CollectionAccessor<M>);
|
|
6
|
+
/**
|
|
7
|
+
* Add a filter condition to your query.
|
|
8
|
+
* @example
|
|
9
|
+
* client.collection('users').where('age', '>=', 18).find()
|
|
10
|
+
*/
|
|
11
|
+
where(column: keyof M & string, operator: FilterOperator, value: unknown): this;
|
|
12
|
+
/**
|
|
13
|
+
* Order the results by a specific column.
|
|
14
|
+
* @example
|
|
15
|
+
* client.collection('users').orderBy('createdAt', 'desc').find()
|
|
16
|
+
*/
|
|
17
|
+
orderBy(column: keyof M & string, ascending?: "asc" | "desc"): this;
|
|
18
|
+
/**
|
|
19
|
+
* Limit the number of results returned.
|
|
20
|
+
*/
|
|
21
|
+
limit(count: number): this;
|
|
22
|
+
/**
|
|
23
|
+
* Skip the first N results.
|
|
24
|
+
*/
|
|
25
|
+
offset(count: number): this;
|
|
26
|
+
/**
|
|
27
|
+
* Set a free-text search string if supported by the backend.
|
|
28
|
+
*/
|
|
29
|
+
search(searchString: string): this;
|
|
30
|
+
/**
|
|
31
|
+
* Include related entities in the response.
|
|
32
|
+
* Relations will be populated with full entity data instead of just IDs.
|
|
33
|
+
*
|
|
34
|
+
* @param relations - Relation names to include, or "*" for all.
|
|
35
|
+
* @example
|
|
36
|
+
* // Include specific relations
|
|
37
|
+
* client.data.posts.include("tags", "author").find()
|
|
38
|
+
*
|
|
39
|
+
* // Include all relations
|
|
40
|
+
* client.data.posts.include("*").find()
|
|
41
|
+
*/
|
|
42
|
+
include(...relations: string[]): this;
|
|
43
|
+
/**
|
|
44
|
+
* Execute the find query and return the results.
|
|
45
|
+
*/
|
|
46
|
+
find(): Promise<FindResponse<M>>;
|
|
47
|
+
/**
|
|
48
|
+
* Listen to realtime updates matching this query.
|
|
49
|
+
*/
|
|
50
|
+
listen(onUpdate: (data: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
|
|
51
|
+
}
|
package/dist/index.d.ts
CHANGED