Skip to content

Commit 8497558

Browse files
Merge pull request #3 from builtio-contentstack/add_param_method
Add param method
2 parents 892bdde + 60c045d commit 8497558

File tree

17 files changed

+84
-197
lines changed

17 files changed

+84
-197
lines changed

dist/native-script/contentstack.js

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -785,12 +785,13 @@ var Stack = function () {
785785
}, {
786786
key: 'Assets',
787787
value: function Assets(uid) {
788-
var asset = new _assets2.default();
789788
this.type = 'asset';
790789
if (uid && typeof uid === "string") {
790+
var asset = new _assets2.default();
791791
asset.asset_uid = uid;
792+
return Utils.merge(asset, this);
792793
}
793-
return Utils.merge(asset, this);
794+
return this;
794795
}
795796

796797
/**
@@ -1472,7 +1473,6 @@ var Query = function (_Entry) {
14721473

14731474
_this._query = _this._query || {};
14741475
_this._query['query'] = _this._query['query'] || {};
1475-
14761476
/**
14771477
* @method lessThan
14781478
* @description This method provides only the entries with values less than the specified value for a field.
@@ -2448,30 +2448,27 @@ var Assets = function () {
24482448
* @example Assets().Query()
24492449
* @returns {Query}
24502450
*/
2451+
// Query() {
2452+
// let query = new Query();
2453+
// return Utils.merge(query, this);
2454+
// }
24512455

2456+
/**
2457+
* @method toJSON
2458+
* @description This method is used to convert the result in to plain javascript object.
2459+
* @example
2460+
* assetQuery
2461+
* .toJSON()
2462+
* .then(function (result) {
2463+
* let value = result.get(field_uid)
2464+
* },function (error) {
2465+
* // error function
2466+
* })
2467+
* @returns {Object}
2468+
*/
24522469

2453-
_createClass(Assets, [{
2454-
key: 'Query',
2455-
value: function Query() {
2456-
var query = new _query2.default();
2457-
return Utils.merge(query, this);
2458-
}
24592470

2460-
/**
2461-
* @method toJSON
2462-
* @description This method is used to convert the result in to plain javascript object.
2463-
* @example
2464-
* assetQuery
2465-
* .toJSON()
2466-
* .then(function (result) {
2467-
* let value = result.get(field_uid)
2468-
* },function (error) {
2469-
* // error function
2470-
* })
2471-
* @returns {Object}
2472-
*/
2473-
2474-
}, {
2471+
_createClass(Assets, [{
24752472
key: 'toJSON',
24762473
value: function toJSON() {
24772474
this.tojson = true;

dist/node/contentstack.js

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -796,12 +796,13 @@ var Stack = function () {
796796
}, {
797797
key: 'Assets',
798798
value: function Assets(uid) {
799-
var asset = new _assets2.default();
800799
this.type = 'asset';
801800
if (uid && typeof uid === "string") {
801+
var asset = new _assets2.default();
802802
asset.asset_uid = uid;
803+
return Utils.merge(asset, this);
803804
}
804-
return Utils.merge(asset, this);
805+
return this;
805806
}
806807

807808
/**
@@ -1938,7 +1939,6 @@ var Query = function (_Entry) {
19381939

19391940
_this._query = _this._query || {};
19401941
_this._query['query'] = _this._query['query'] || {};
1941-
19421942
/**
19431943
* @method lessThan
19441944
* @description This method provides only the entries with values less than the specified value for a field.
@@ -7121,30 +7121,27 @@ var Assets = function () {
71217121
* @example Assets().Query()
71227122
* @returns {Query}
71237123
*/
7124+
// Query() {
7125+
// let query = new Query();
7126+
// return Utils.merge(query, this);
7127+
// }
71247128

7129+
/**
7130+
* @method toJSON
7131+
* @description This method is used to convert the result in to plain javascript object.
7132+
* @example
7133+
* assetQuery
7134+
* .toJSON()
7135+
* .then(function (result) {
7136+
* let value = result.get(field_uid)
7137+
* },function (error) {
7138+
* // error function
7139+
* })
7140+
* @returns {Object}
7141+
*/
71257142

7126-
_createClass(Assets, [{
7127-
key: 'Query',
7128-
value: function Query() {
7129-
var query = new _query2.default();
7130-
return Utils.merge(query, this);
7131-
}
71327143

7133-
/**
7134-
* @method toJSON
7135-
* @description This method is used to convert the result in to plain javascript object.
7136-
* @example
7137-
* assetQuery
7138-
* .toJSON()
7139-
* .then(function (result) {
7140-
* let value = result.get(field_uid)
7141-
* },function (error) {
7142-
* // error function
7143-
* })
7144-
* @returns {Object}
7145-
*/
7146-
7147-
}, {
7144+
_createClass(Assets, [{
71487145
key: 'toJSON',
71497146
value: function toJSON() {
71507147
this.tojson = true;

dist/react-native/contentstack.js

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -785,12 +785,13 @@ var Stack = function () {
785785
}, {
786786
key: 'Assets',
787787
value: function Assets(uid) {
788-
var asset = new _assets2.default();
789788
this.type = 'asset';
790789
if (uid && typeof uid === "string") {
790+
var asset = new _assets2.default();
791791
asset.asset_uid = uid;
792+
return Utils.merge(asset, this);
792793
}
793-
return Utils.merge(asset, this);
794+
return this;
794795
}
795796

796797
/**
@@ -1472,7 +1473,6 @@ var Query = function (_Entry) {
14721473

14731474
_this._query = _this._query || {};
14741475
_this._query['query'] = _this._query['query'] || {};
1475-
14761476
/**
14771477
* @method lessThan
14781478
* @description This method provides only the entries with values less than the specified value for a field.
@@ -2448,30 +2448,27 @@ var Assets = function () {
24482448
* @example Assets().Query()
24492449
* @returns {Query}
24502450
*/
2451+
// Query() {
2452+
// let query = new Query();
2453+
// return Utils.merge(query, this);
2454+
// }
24512455

2456+
/**
2457+
* @method toJSON
2458+
* @description This method is used to convert the result in to plain javascript object.
2459+
* @example
2460+
* assetQuery
2461+
* .toJSON()
2462+
* .then(function (result) {
2463+
* let value = result.get(field_uid)
2464+
* },function (error) {
2465+
* // error function
2466+
* })
2467+
* @returns {Object}
2468+
*/
24522469

2453-
_createClass(Assets, [{
2454-
key: 'Query',
2455-
value: function Query() {
2456-
var query = new _query2.default();
2457-
return Utils.merge(query, this);
2458-
}
24592470

2460-
/**
2461-
* @method toJSON
2462-
* @description This method is used to convert the result in to plain javascript object.
2463-
* @example
2464-
* assetQuery
2465-
* .toJSON()
2466-
* .then(function (result) {
2467-
* let value = result.get(field_uid)
2468-
* },function (error) {
2469-
* // error function
2470-
* })
2471-
* @returns {Object}
2472-
*/
2473-
2474-
}, {
2471+
_createClass(Assets, [{
24752472
key: 'toJSON',
24762473
value: function toJSON() {
24772474
this.tojson = true;

dist/web/contentstack.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/node/contentstack-demo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ContentstackDemo {
2323
*/
2424
getEntries(contentTypeUid) {
2525
contentTypeUid = contentTypeUid || 'source'
26-
return this.Stack.ContentType(contentTypeUid).Query().toJSON().find()
26+
return this.Stack.ContentType(contentTypeUid).Query().where('title', "hometestfinal").toJSON().find()
2727
}
2828

2929
/**
@@ -55,7 +55,7 @@ class ContentstackDemo {
5555
*/
5656
getAsset(assetUid) {
5757
assetUid = assetUid || 'blt123something'
58-
return this.Stack.Assets(assetUid).fetch()
58+
return this.Stack.Assets(assetUid).addParam('include_dimension', 'true').fetch()
5959
}
6060

6161
}

js-sdk-reference/global.html

Lines changed: 3 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ <h5>Parameters:</h5>
13311331

13321332
<h5>Example</h5>
13331333

1334-
<pre class="prettyprint"><code>Stack.Assets('blt1234567890abcef')</code></pre>
1334+
<pre class="prettyprint"><code>Stack.Assets('blt1234567890abcef').fetch</code></pre>
13351335

13361336

13371337

@@ -1728,85 +1728,6 @@ <h5>Examples</h5>
17281728

17291729

17301730

1731-
<h4 class="name" id="Query"><span class="type-signature"></span>Query<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#Query">Query</a>}</span></h4>
1732-
1733-
1734-
1735-
1736-
1737-
<div class="description">
1738-
Query instance to provide support for all search queries.
1739-
</div>
1740-
1741-
1742-
1743-
1744-
1745-
1746-
1747-
1748-
1749-
1750-
1751-
1752-
1753-
<dl class="details">
1754-
1755-
1756-
1757-
1758-
1759-
1760-
1761-
1762-
1763-
1764-
1765-
1766-
1767-
1768-
1769-
1770-
1771-
1772-
1773-
1774-
1775-
1776-
1777-
1778-
1779-
1780-
1781-
1782-
1783-
1784-
</dl>
1785-
1786-
1787-
1788-
1789-
1790-
1791-
1792-
1793-
1794-
1795-
1796-
1797-
1798-
<h5>Example</h5>
1799-
1800-
<pre class="prettyprint"><code>Assets().Query()</code></pre>
1801-
1802-
1803-
1804-
1805-
1806-
1807-
1808-
1809-
18101731
<h4 class="name" id="toJSON"><span class="type-signature"></span>toJSON<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
18111732

18121733

@@ -3069,7 +2990,7 @@ <h5>Example</h5>
30692990

30702991

30712992

3072-
<h4 class="name" id="AddParam"><span class="type-signature"></span>AddParam<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#Query">Query</a>}</span></h4>
2993+
<h4 class="name" id="AddParam"><span class="type-signature"></span>AddParam<span class="signature">()</span><span class="type-signature"></span></h4>
30732994

30742995

30752996

@@ -3138,7 +3059,7 @@ <h4 class="name" id="AddParam"><span class="type-signature"></span>AddParam<span
31383059

31393060
<h5>Example</h5>
31403061

3141-
<pre class="prettyprint"><code>blogQuery.addParam('include_count', 'true')</code></pre>
3062+
<pre class="prettyprint"><code>blogQuery.addParam('include_count', 'true').fetch()</code></pre>
31423063

31433064

31443065

js-sdk-reference/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h1 class="page-title">Contentstack - Javascript SDK</h1>
3333
<h2><a id="JavaScript_SDK_for_Contentstack_1"></a>JavaScript SDK for Contentstack</h2>
3434
<p>Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. <a href="https://www.contentstack.com/">Read More</a>.</p>
3535
<p>Contentstack provides JavaScript SDK to build application on top of JavaScript. Given below is the detailed guide and helpful resources to get started with our JavaScript SDK.</p>
36-
<p>The JavaScript SDK can also be used to create Node.js and React native applications.</p>
36+
<p>The JavaScript SDK can also be used to create Node.js and React Native applications.</p>
3737
<h3><a id="Prerequisite_9"></a>Prerequisite</h3>
3838
<p>You need Node.js version 4.4.7 or later installed to use the Contentstack JavaScript SDK.</p>
3939
<h3><a id="Setup_and_Installation_13"></a>Setup and Installation</h3>

js-sdk-reference/modules_assets.js.html

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,6 @@ <h1 class="page-title">modules/assets.js</h1>
7373
return this;
7474
}
7575

76-
/**
77-
* @method Query
78-
* @description Query instance to provide support for all search queries.
79-
* @example Assets().Query()
80-
* @returns {Query}
81-
*/
82-
Query() {
83-
let query = new Query();
84-
return Utils.merge(query, this);
85-
}
86-
8776
/**
8877
* @method toJSON
8978
* @description This method is used to convert the result in to plain javascript object.

js-sdk-reference/modules_entry.js.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ <h1 class="page-title">modules/entry.js</h1>
233233
/**
234234
* @method AddParam
235235
* @description This method includes query parameter in query.
236-
* @example blogQuery.addParam('include_count', 'true')
237-
* @returns {Query}
236+
* @example blogQuery.addParam('include_count', 'true').fetch()
238237
*/
239238
addParam(key, value) {
240239
if (key &amp;&amp; value &amp;&amp; typeof key === 'string' &amp;&amp; typeof value === 'string') {

js-sdk-reference/modules_query.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ <h1 class="page-title">modules/query.js</h1>
129129
* @ignore
130130
*/
131131
export default class Query extends Entry {
132+
132133
constructor() {
133134
super();
134135
this._query = this._query || {};
135136
this._query['query'] = this._query['query'] || {};
136-
137137
/**
138138
* @method lessThan
139139
* @description This method provides only the entries with values less than the specified value for a field.

0 commit comments

Comments
 (0)