Skip to content

Commit 50b82ba

Browse files
Merge pull request #163 from contentstack/v4-beta/next
V4 beta/next
2 parents 0331739 + 5b76dc6 commit 50b82ba

File tree

6 files changed

+351
-32
lines changed

6 files changed

+351
-32
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Change log
22

3+
### Version: 4.0.0-beta.5
4+
#### Date: March-26-2024
5+
##### New Features:
6+
- Query operators implementation-2
7+
38
### Version: 4.0.0-beta.4
49
#### Date: March-14-2024
510
##### New Features:

package-lock.json

+24-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/delivery-sdk",
3-
"version": "4.0.0-beta.4",
3+
"version": "4.0.0-beta.5",
44
"type": "commonjs",
55
"main": "./dist/cjs/src/index.js",
66
"types": "./dist/types/src/index.d.ts",
@@ -24,8 +24,9 @@
2424
},
2525
"dependencies": {
2626
"@contentstack/core": "^1.0.1",
27-
"@contentstack/utils": "^1.3.1",
27+
"@contentstack/utils": "^1.3.3",
2828
"@types/humps": "^2.0.6",
29+
"axios": "^1.6.8",
2930
"dotenv": "^16.3.1",
3031
"humps": "^2.0.1"
3132
},

src/lib/query.ts

+147-3
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,24 @@ export class Query extends BaseQuery {
201201
return this;
202202
}
203203

204+
/**
205+
* @method exists
206+
* @memberof Query
207+
* @description Returns the raw (JSON) query based on the filters applied on Query object.
208+
* @example
209+
* import contentstack from '@contentstack/delivery-sdk'
210+
*
211+
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
212+
* const query = stack.contentType("contentTypeUid").entry().query();
213+
* const result = await query.exists('fieldUid').find()
214+
*
215+
* @returns {Query}
216+
*/
217+
exists(key: string): Query {
218+
this._parameters[key] = { '$exists': true };
219+
return this;
220+
}
221+
204222
/**
205223
* @method notExists
206224
* @memberof Query
@@ -291,12 +309,138 @@ export class Query extends BaseQuery {
291309
*
292310
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
293311
* const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value');
294-
* const entryQuery = await stack.contentType('contenttype_uid').query().referenceIn('reference_uid', query).find<TEntry>();
312+
* const entryQuery = await stack.contentType('contenttype_uid').query().referenceIn('reference_uid', query).find();
295313
*
296314
* @returns {Query}
297315
*/
298-
referenceIn(key: string, query: Query) {
316+
referenceIn(key: string, query: Query): Query {
299317
this._parameters[key] = { '$in_query': query._parameters }
300318
return this;
301-
}
319+
}
320+
321+
/**
322+
* @method referenceNotIn
323+
* @memberof Query
324+
* @description Returns the raw (JSON) query based on the filters applied on Query object.
325+
* @example
326+
* import contentstack from '@contentstack/delivery-sdk'
327+
*
328+
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
329+
* const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value');
330+
* const entryQuery = await stack.contentType('contenttype_uid').query().referenceNotIn('reference_uid', query).find();
331+
*
332+
* @returns {Query}
333+
*/
334+
referenceNotIn(key: string, query: Query): Query {
335+
this._parameters[key] = { '$nin_query': query._parameters }
336+
return this;
337+
}
338+
339+
/**
340+
* @method tags
341+
* @memberof Query
342+
* @description Returns the raw (JSON) query based on the filters applied on Query object.
343+
* @example
344+
* import contentstack from '@contentstack/delivery-sdk'
345+
*
346+
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
347+
* const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value');
348+
* const entryQuery = await stack.contentType('contenttype_uid').query().tags(['tag1']).find();
349+
*
350+
* @returns {Query}
351+
*/
352+
tags(values: (string | number | boolean)[]): Query {
353+
this._parameters['tags'] = values;
354+
return this;
355+
}
356+
357+
/**
358+
* @method search
359+
* @memberof Query
360+
* @description Returns the raw (JSON) query based on the filters applied on Query object.
361+
* @example
362+
* import contentstack from '@contentstack/delivery-sdk'
363+
*
364+
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
365+
* const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value');
366+
* const entryQuery = await stack.contentType('contenttype_uid').query().search('key').find();
367+
*
368+
* @returns {Query}
369+
*/
370+
search(key: string): Query {
371+
this._queryParams['typeahead'] = key
372+
return this
373+
}
374+
375+
/**
376+
* @method lessThan
377+
* @memberof Query
378+
* @description Returns the raw (JSON) query based on the filters applied on Query object.
379+
* @example
380+
* import contentstack from '@contentstack/delivery-sdk'
381+
*
382+
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
383+
* const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value');
384+
* const entryQuery = await stack.contentType('contenttype_uid').query().lessThan('fieldUid', 'value').find();
385+
*
386+
* @returns {Query}
387+
*/
388+
lessThan(key: string, value: (string | number)): Query {
389+
this._parameters[key] = { '$lt': value };
390+
return this;
391+
}
392+
393+
/**
394+
* @method lessThanOrEqualTo
395+
* @memberof Query
396+
* @description Returns the raw (JSON) query based on the filters applied on Query object.
397+
* @example
398+
* import contentstack from '@contentstack/delivery-sdk'
399+
*
400+
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
401+
* const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value');
402+
* const entryQuery = await stack.contentType('contenttype_uid').query().lessThanOrEqualTo('fieldUid', 'value').find();
403+
*
404+
* @returns {Query}
405+
*/
406+
lessThanOrEqualTo(key: string, value: (string | number)): Query {
407+
this._parameters[key] = { '$lte': value };
408+
return this;
409+
}
410+
411+
/**
412+
* @method greaterThan
413+
* @memberof Query
414+
* @description Returns the raw (JSON) query based on the filters applied on Query object.
415+
* @example
416+
* import contentstack from '@contentstack/delivery-sdk'
417+
*
418+
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
419+
* const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value');
420+
* const entryQuery = await stack.contentType('contenttype_uid').query().greaterThan('fieldUid', 'value').find();
421+
*
422+
* @returns {Query}
423+
*/
424+
greaterThan(key: string, value: (string | number)): Query {
425+
this._parameters[key] = { '$gt': value };
426+
return this;
427+
}
428+
429+
/**
430+
* @method greaterThanOrEqualTo
431+
* @memberof Query
432+
* @description Returns the raw (JSON) query based on the filters applied on Query object.
433+
* @example
434+
* import contentstack from '@contentstack/delivery-sdk'
435+
*
436+
* const stack = contentstack.Stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
437+
* const query = stack.contentType('contenttype_uid').query().where('title', QueryOperation.EQUALS, 'value');
438+
* const entryQuery = await stack.contentType('contenttype_uid').query().greaterThanOrEqualTo('fieldUid', 'value').find();
439+
*
440+
* @returns {Query}
441+
*/
442+
greaterThanOrEqualTo(key: string, value: (string | number)): Query {
443+
this._parameters[key] = { '$gte': value };
444+
return this;
445+
}
302446
}

0 commit comments

Comments
 (0)