@frenchbaas/js 0.2.4 → 0.3.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.
package/README.md CHANGED
@@ -49,6 +49,12 @@ const col = client.collection('uuid-de-la-collection')
49
49
  const { data, meta } = await col.get({ page: 1, perPage: 20 })
50
50
  // meta → { total, page, per_page, total_pages }
51
51
 
52
+ // Filtrer par champ (string, number, boolean)
53
+ const { data: pending } = await col.get({ filter: { status: 'pending' } })
54
+
55
+ // Filtrer par champ references (tableau d'UUIDs — contient l'UUID)
56
+ const { data: products } = await col.get({ filter: { category_ids: 'uuid-categorie' } })
57
+
52
58
  // Récupérer un document par ID
53
59
  const doc = await col.getById('doc-uuid')
54
60
  // doc → { id, data, created_at, updated_at }
package/dist/index.cjs CHANGED
@@ -209,6 +209,11 @@ var CollectionClient = class {
209
209
  page: options.page,
210
210
  per_page: options.perPage
211
211
  };
212
+ if (options.filter) {
213
+ for (const [key, val] of Object.entries(options.filter)) {
214
+ if (val !== void 0) params[`filter[${key}]`] = val;
215
+ }
216
+ }
212
217
  const res = await this._http.get(
213
218
  `/sdk/collections/${this._collectionId}/documents`,
214
219
  params
package/dist/index.d.mts CHANGED
@@ -47,6 +47,15 @@ interface GetOptions {
47
47
  page?: number;
48
48
  /** Documents par page — max 100 (défaut: 50) */
49
49
  perPage?: number;
50
+ /**
51
+ * Filtres sur les champs du document.
52
+ * - Champ string/number/boolean : égalité exacte
53
+ * - Champ references : l'UUID doit être présent dans le tableau
54
+ *
55
+ * @example { status: 'pending' }
56
+ * @example { category_ids: '3e0a5843-...' }
57
+ */
58
+ filter?: Record<string, string>;
50
59
  }
51
60
  type FieldType = 'string' | 'integer' | 'number' | 'boolean' | 'array' | 'object' | 'datetime';
52
61
  interface SchemaField {
package/dist/index.d.ts CHANGED
@@ -47,6 +47,15 @@ interface GetOptions {
47
47
  page?: number;
48
48
  /** Documents par page — max 100 (défaut: 50) */
49
49
  perPage?: number;
50
+ /**
51
+ * Filtres sur les champs du document.
52
+ * - Champ string/number/boolean : égalité exacte
53
+ * - Champ references : l'UUID doit être présent dans le tableau
54
+ *
55
+ * @example { status: 'pending' }
56
+ * @example { category_ids: '3e0a5843-...' }
57
+ */
58
+ filter?: Record<string, string>;
50
59
  }
51
60
  type FieldType = 'string' | 'integer' | 'number' | 'boolean' | 'array' | 'object' | 'datetime';
52
61
  interface SchemaField {
package/dist/index.js CHANGED
@@ -175,6 +175,11 @@ var CollectionClient = class {
175
175
  page: options.page,
176
176
  per_page: options.perPage
177
177
  };
178
+ if (options.filter) {
179
+ for (const [key, val] of Object.entries(options.filter)) {
180
+ if (val !== void 0) params[`filter[${key}]`] = val;
181
+ }
182
+ }
178
183
  const res = await this._http.get(
179
184
  `/sdk/collections/${this._collectionId}/documents`,
180
185
  params
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frenchbaas/js",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "SDK JavaScript officiel pour FrenchBaas",
5
5
  "author": "FrenchBaas",
6
6
  "license": "MIT",