@@ -277,15 +277,40 @@ function resultWrapper(result) {
277277 return result ;
278278} ;
279279
280+ // // spread the result object
281+ // export function spreadResult(result) {
282+ // let _results = [];
283+ // if (result && Object.keys(result).length) {
284+ // if (typeof result.entries !== 'undefined') _results.push(result.entries);
285+ // if (typeof result.assets !== 'undefined') _results.push(result.assets);
286+ // if (typeof result.content_type !== 'undefined' || typeof result.schema !== 'undefined') _results.push(result.content_type || result.schema);
287+ // if (typeof result.count !== 'undefined') _results.push(result.count);
288+ // if (typeof result.entry !== 'undefined') _results = result.entry;
289+ // if (typeof result.asset !== 'undefined') _results = result.asset;
290+ // if (typeof result.items !== 'undefined') _results.push(result);
291+ // }
292+ // return _results;
293+ // };
294+
280295// spread the result object
281296function spreadResult ( result ) {
282297 var _results = [ ] ;
283298 if ( result && Object . keys ( result ) . length ) {
284- if ( typeof result . entries !== 'undefined' ) _results . push ( result . entries ) ;
299+ if ( typeof result . entries !== 'undefined' ) {
300+ _results . push ( result . entries ) ;
301+ if ( result . content_type ) {
302+ _results [ 'schema' ] = result . content_type ;
303+ }
304+ }
285305 if ( typeof result . assets !== 'undefined' ) _results . push ( result . assets ) ;
286306 if ( typeof result . content_type !== 'undefined' || typeof result . schema !== 'undefined' ) _results . push ( result . content_type || result . schema ) ;
287307 if ( typeof result . count !== 'undefined' ) _results . push ( result . count ) ;
288- if ( typeof result . entry !== 'undefined' ) _results = result . entry ;
308+ if ( typeof result . entry !== 'undefined' ) {
309+ _results = result . entry ;
310+ if ( result . schema ) {
311+ _results [ 'schema' ] = result . schema ;
312+ }
313+ }
289314 if ( typeof result . asset !== 'undefined' ) _results = result . asset ;
290315 if ( typeof result . items !== 'undefined' ) _results . push ( result ) ;
291316 }
@@ -1564,7 +1589,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
15641589function _interopRequireWildcard ( obj ) { if ( obj && obj . __esModule ) { return obj ; } else { var newObj = { } ; if ( obj != null ) { for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) newObj [ key ] = obj [ key ] ; } } newObj . default = obj ; return newObj ; } }
15651590
15661591//JS SDK version
1567- var version = '3.7 .1' ;
1592+ var version = '3.8 .1' ;
15681593var environment = void 0 ,
15691594 api_key = void 0 ;
15701595
@@ -2662,6 +2687,14 @@ var Query = function (_Entry) {
26622687 * @param {object } query - RAW (JSON) queries
26632688 * @returns {Query }
26642689 * @instance
2690+ * @example
2691+ * let blogQuery = Stack().ContentType('example').Query();
2692+ * let data = blogQuery.query({"brand": {"$nin_query": {"title": "Apple Inc."}}}).find()
2693+ * data.then(function(result) {
2694+ * // ‘result’ contains the total count.
2695+ * },function (error) {
2696+ * // error function
2697+ * })
26652698 */
26662699
26672700 } , {
@@ -2675,6 +2708,97 @@ var Query = function (_Entry) {
26752708 }
26762709 }
26772710
2711+ /**
2712+ * @method referenceIn
2713+ * @memberOf Query
2714+ * @description Retrieve entries that satisfy the query conditions made on referenced fields.
2715+ * @param {Query } query - RAW (JSON) queries
2716+ * @returns {Query }
2717+ * @instance
2718+ * @example
2719+ * <caption> referenceIn with Query instances</caption>
2720+ * let blogQuery = Stack().ContentType('example').Query();
2721+ * let Query = Stack.ContentType('blog').Query().where('title', 'Demo').find()
2722+ * let data = blogQuery.referenceIn("brand", Query).find()
2723+ * data.then(function(result) {
2724+ * // ‘result’ contains the total count.
2725+ * },function (error) {
2726+ * // error function
2727+ * })
2728+ *
2729+ * @example
2730+ * <caption> referenceIn with raw queries</caption>
2731+ * let blogQuery = Stack().ContentType('example').Query();
2732+ * let data = blogQuery.referenceIn("brand", {'title': 'Demo'}).find()
2733+ * data.then(function(result) {
2734+ * // ‘result’ contains the total count.
2735+ * },function (error) {
2736+ * // error function
2737+ * })
2738+ */
2739+
2740+ } , {
2741+ key : 'referenceIn' ,
2742+ value : function referenceIn ( key , query ) {
2743+ var _query = { } ;
2744+ if ( query instanceof Query && query . _query . query ) {
2745+ _query [ "$in_query" ] = query . _query . query ;
2746+ } else if ( ( typeof query === 'undefined' ? 'undefined' : _typeof ( query ) ) === "object" ) {
2747+ _query [ "$in_query" ] = query ;
2748+ }
2749+ if ( this . _query [ 'query' ] [ key ] ) {
2750+ this . _query [ 'query' ] [ key ] = this . _query [ 'query' ] [ key ] . concat ( _query ) ;
2751+ } else {
2752+ this . _query [ 'query' ] [ key ] = _query ;
2753+ }
2754+ return this ;
2755+ }
2756+
2757+ /**
2758+ * @method referenceNotIn
2759+ * @memberOf Query
2760+ * @description Retrieve entries that does not satisfy the query conditions made on referenced fields.
2761+ * @param {Query } query - RAW (JSON) queries
2762+ * @returns {Query }
2763+ * @instance
2764+ * @example
2765+ * <caption> referenceNotIn with Query instances</caption>
2766+ * let blogQuery = Stack().ContentType('example').Query();
2767+ * let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
2768+ * data.then(function(result) {
2769+ * // ‘result’ contains the total count.
2770+ * },function (error) {
2771+ * // error function
2772+ * })
2773+ *
2774+ * @example
2775+ * <caption> referenceNotIn with raw queries</caption>
2776+ * let blogQuery = Stack().ContentType('example').Query();
2777+ * let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
2778+ * data.then(function(result) {
2779+ * // ‘result’ contains the total count.
2780+ * },function (error) {
2781+ * // error function
2782+ * })
2783+ */
2784+
2785+ } , {
2786+ key : 'referenceNotIn' ,
2787+ value : function referenceNotIn ( key , query ) {
2788+ var _query = { } ;
2789+ if ( query instanceof Query && query . _query . query ) {
2790+ _query [ "$nin_query" ] = query . _query . query ;
2791+ } else if ( ( typeof query === 'undefined' ? 'undefined' : _typeof ( query ) ) === "object" ) {
2792+ _query [ "$nin_query" ] = query ;
2793+ }
2794+ if ( this . _query [ 'query' ] [ key ] ) {
2795+ this . _query [ 'query' ] [ key ] = this . _query [ 'query' ] [ key ] . concat ( _query ) ;
2796+ } else {
2797+ this . _query [ 'query' ] [ key ] = _query ;
2798+ }
2799+ return this ;
2800+ }
2801+
26782802 /**
26792803 * @method tags
26802804 * @memberOf Query
@@ -2750,18 +2874,18 @@ var Query = function (_Entry) {
27502874 }
27512875
27522876 /**
2753- * @method addParam
2754- * @description Includes query parameters in your queries.
2755- * @memberOf Query
2756- * @example var data = blogQuery.addParam('include_count', 'true').fetch()
2757- * data.then(function (result) {
2758- * // 'result' is an object which content the data including count in json object form
2759- * },function (error) {
2760- * // error function
2761- * })
2762- * @returns {Query }
2763- * @instance
2764- */
2877+ * @method addParam
2878+ * @description Includes query parameters in your queries.
2879+ * @memberOf Query
2880+ * @example var data = blogQuery.addParam('include_count', 'true').fetch()
2881+ * data.then(function (result) {
2882+ * // 'result' is an object which content the data including count in json object form
2883+ * },function (error) {
2884+ * // error function
2885+ * })
2886+ * @returns {Query }
2887+ * @instance
2888+ */
27652889
27662890 } , {
27672891 key : 'addParam' ,
@@ -2877,7 +3001,6 @@ var Query = function (_Entry) {
28773001 query : this . _query
28783002 }
28793003 } ;
2880-
28813004 return Utils . sendRequest ( this ) ;
28823005 }
28833006
0 commit comments