@@ -463,6 +463,14 @@ export default class Query extends Entry {
463
463
* @param {object } query - RAW (JSON) queries
464
464
* @returns {Query }
465
465
* @instance
466
+ * @example
467
+ * let blogQuery = Stack().ContentType('example').Query();
468
+ * let data = blogQuery.query({"brand": {"$nin_query": {"title": "Apple Inc."}}}).find()
469
+ * data.then(function(result) {
470
+ * // ‘result’ contains the total count.
471
+ * },function (error) {
472
+ * // error function
473
+ * })
466
474
*/
467
475
query ( query ) {
468
476
if ( typeof query === "object" ) {
@@ -473,6 +481,92 @@ export default class Query extends Entry {
473
481
}
474
482
}
475
483
484
+ /**
485
+ * @method referenceIn
486
+ * @memberOf Query
487
+ * @description Retrieve entries that satisfy the query conditions made on referenced fields.
488
+ * @param {Query } query - RAW (JSON) queries
489
+ * @returns {Query }
490
+ * @instance
491
+ * @example
492
+ * <caption> referenceIn with Query instances</caption>
493
+ * let blogQuery = Stack().ContentType('example').Query();
494
+ * let Query = Stack.ContentType('blog').Query().where('title', 'Demo').find()
495
+ * let data = blogQuery.referenceIn("brand", Query).find()
496
+ * data.then(function(result) {
497
+ * // ‘result’ contains the total count.
498
+ * },function (error) {
499
+ * // error function
500
+ * })
501
+ *
502
+ * @example
503
+ * <caption> referenceIn with raw queries</caption>
504
+ * let blogQuery = Stack().ContentType('example').Query();
505
+ * let data = blogQuery.referenceIn("brand", {'title': 'Demo'}).find()
506
+ * data.then(function(result) {
507
+ * // ‘result’ contains the total count.
508
+ * },function (error) {
509
+ * // error function
510
+ * })
511
+ */
512
+ referenceIn ( key , query ) {
513
+ var _query = { }
514
+ if ( query instanceof Query && query . _query . query ) {
515
+ _query [ "$in_query" ] = query . _query . query ;
516
+ } else if ( typeof query === "object" ) {
517
+ _query [ "$in_query" ] = query ;
518
+ }
519
+ if ( this . _query [ 'query' ] [ key ] ) {
520
+ this . _query [ 'query' ] [ key ] = this . _query [ 'query' ] [ key ] . concat ( _query ) ;
521
+ } else {
522
+ this . _query [ 'query' ] [ key ] = _query ;
523
+ }
524
+ return this ;
525
+ }
526
+
527
+
528
+ /**
529
+ * @method referenceNotIn
530
+ * @memberOf Query
531
+ * @description Retrieve entries that does not satisfy the query conditions made on referenced fields.
532
+ * @param {Query } query - RAW (JSON) queries
533
+ * @returns {Query }
534
+ * @instance
535
+ * @example
536
+ * <caption> referenceNotIn with Query instances</caption>
537
+ * let blogQuery = Stack().ContentType('example').Query();
538
+ * let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
539
+ * data.then(function(result) {
540
+ * // ‘result’ contains the total count.
541
+ * },function (error) {
542
+ * // error function
543
+ * })
544
+ *
545
+ * @example
546
+ * <caption> referenceNotIn with raw queries</caption>
547
+ * let blogQuery = Stack().ContentType('example').Query();
548
+ * let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
549
+ * data.then(function(result) {
550
+ * // ‘result’ contains the total count.
551
+ * },function (error) {
552
+ * // error function
553
+ * })
554
+ */
555
+ referenceNotIn ( key , query ) {
556
+ var _query = { }
557
+ if ( query instanceof Query && query . _query . query ) {
558
+ _query [ "$nin_query" ] = query . _query . query ;
559
+ } else if ( typeof query === "object" ) {
560
+ _query [ "$nin_query" ] = query ;
561
+ }
562
+ if ( this . _query [ 'query' ] [ key ] ) {
563
+ this . _query [ 'query' ] [ key ] = this . _query [ 'query' ] [ key ] . concat ( _query ) ;
564
+ } else {
565
+ this . _query [ 'query' ] [ key ] = _query ;
566
+ }
567
+ return this ;
568
+ }
569
+
476
570
/**
477
571
* @method tags
478
572
* @memberOf Query
@@ -539,7 +633,7 @@ export default class Query extends Entry {
539
633
return this ;
540
634
}
541
635
542
- /**
636
+ /**
543
637
* @method addParam
544
638
* @description Includes query parameters in your queries.
545
639
* @memberOf Query
0 commit comments