Methods
and(queries) → {this}
Retrieve entries that satisfy all the provided conditions.
Parameters:
Name |
Type |
Description |
queries |
object
|
array of query objects or raw queries. |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let Query1 = Stack.contentType('example').entries().equalTo('title', 'Demo')
let Query2 = Stack.contentType('example').entries().lessThan('comments', 10)
blogQuery.and(Query1, Query2).find()
ascending(key) → {this}
Sort fetched entries in the ascending order with respect to a specific field.
Parameters:
Name |
Type |
Description |
key |
String
|
field uid based on which the ordering will be done |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.ascending('created_at').find()
data.then((result) => {
// ‘result’ contains the list of entries which is sorted in
//ascending order on the basis of ‘created_at’.
}).catch((error) => {
// error trace
})
asset(uid-) → {this}
To get single asset
Parameters:
Name |
Type |
Description |
uid- |
string
|
Optional. uid of asset |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.asset('bltabced12435').find()
//or
Stack.asset().find()
assets() → {this}
Get assets details
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.assets().find()
connect(overrides) → {string}
Establish connection to filesytem
TODO
Parameters:
Name |
Type |
Description |
overrides |
Object
|
Config overrides/flesystem specific config |
- Source:
Returns:
baseDir
-
Type
-
string
Example
Stack.connect({overrides})
.then((result) => {
// db instance
})
.catch((error) => {
// handle query errors
})
containedIn(key, value) → {this}
Retrieve entries in which the value of a field matches with any of the provided array of values
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
value |
*
|
Array of values that are to be used to match or compare |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries().query();
let data = blogQuery.containedIn('title', ['Demo', 'Welcome']).find()
data.then((result) => {
// ‘result’ contains the list of entries where value of the
// ‘title’ field will contain either 'Demo' or ‘Welcome’.
}).catch((error) => {
// error trace
})
contentType(uid) → {this|Stack}
Content type to query on
Parameters:
Name |
Type |
Description |
uid |
String
|
Content type uid |
- Source:
Returns:
Example
Stack.contentType('example').entries().find()
.then((result) => {
// returns entries filtered based on 'example' content type
})
.catch((error) => {
// handle query errors
})
contentTypes() → {this}
Get content type schemas
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentTypes().find()
count() → {this}
Returns the total number of entries
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
const query = Stack.contentType('example').entries().count().find()
query.then((result) => {
// returns 'example' content type's entries
}).catch(error) => {
// error trace
})
descending(key) → {this}
Sort fetched entries in the descending order with respect to a specific field
Parameters:
Name |
Type |
Description |
key |
String
|
field uid based on which the ordering will be done. |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.descending('created_at').find()
data.then((result) => {
// ‘result’ contains the list of entries which is sorted in
//descending order on the basis of ‘created_at’.
}).catch((error) => {
// error trace
})
entries() → {this}
To get entries from contentType
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example')
.entries()
.find()
entry(uid-) → {this}
To get entry from contentType
Parameters:
Name |
Type |
Description |
uid- |
string
|
Optional. uid of entry |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example').entry('bltabcd12345').find()
//or
Stack.contentType('example').entry().find()
equalTo(key, value) → {this}
Retrieve entries in which a specific field satisfies the value provided
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
value |
Any
|
value used to match or compare |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.equalTo('title','Demo').find()
data.then((result) => {
// ‘result’ contains the list of entries where value of
//‘title’ is equal to ‘Demo’.
}).catch((error) => {
// error trace
})
except(result) → {this}
Similar to MongoDB projections. Accepts an array.
Only fields mentioned in the array would be removed from the result.
Parameters:
Name |
Type |
Description |
result |
Array
|
Array of field properties |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
const query = Stack.contentType('example').entries().except(['title','uid']).find()
query.then((result) => {
// ‘result’ contains a list of entries with field title and uid only
}).catch((error) => {
// error trace
})
excludeReferences() → {this}
Excludes all references of the entries being scanned
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example')
.entries()
.excludeReferences()
.find()
.then((result) => {
// ‘result’ entries without references
}).catch((error) => {
// error trace
})
exists(key) → {this}
Retrieve entries if value of the field, mentioned in the condition, exists.
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.exists('featured').find()
data.then((result) => {
// ‘result’ contains the list of entries in which "featured" exists.
}).catch((error) => {
// error trace
})
find(query) → {object}
Queries the db using the query built/passed
Does all the processing, filtering, referencing after querying the DB
Parameters:
Name |
Type |
Description |
query |
object
|
Optional query object, that overrides all the
previously build queries |
- Source:
Returns:
- Returns a objects, that have been processed, filtered and referenced
-
Type
-
object
Example
Stack.contentType('blog').entries().find()
.then((result) => {
// returns blog content type's entries
})
.catch((error) => {
// handle query errors
})
findOne(query) → {object}
Queries the db using the query built/passed. Returns a single entry/asset/content type object
Does all the processing, filtering, referencing after querying the DB
Parameters:
Name |
Type |
Description |
query |
object
|
Optional query object, that overrides all the previously build queries |
- Source:
Returns:
- Returns an object, that has been processed, filtered and referenced
-
Type
-
object
Example
Stack.contentType('blog')
.entries()
.findOne()
getAssetsPath(locale)
Parameters:
Name |
Type |
Description |
locale |
|
Locale from which the contents have to be read |
- Source:
getContentTypesPath(locale)
Parameters:
Name |
Type |
Description |
locale |
|
Locale from which the contents have to be read |
- Source:
getEntriesPath(contentTypeUid, locale)
Parameters:
Name |
Type |
Description |
contentTypeUid |
|
Content type - uid, who's entries are to be fetched |
locale |
|
Locale from which the contents have to be read |
- Source:
getQuery() → {this}
Returns the raw (JSON) query based on the filters applied on Query object.
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example')
.eqaulTo('title','Demo')
.getQuery()
.find()
greaterThan(key, value) → {this}
Retrieves entries in which the value for a field is greater than the provided value.
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
value |
*
|
value used to match or compare |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.greaterThan('created_at','2015-03-12').find()
data.then((result) => {
// result contains the data of entries where the
//'created_at' date will be greaterthan '2015-06-22'
}).catch((error) => {
// error trace
})
greaterThanOrEqualTo(key, value) → {this}
Retrieves entries in which the value for a field is greater than or equal to the provided value.
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
value |
*
|
Value used to match or compare |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.greaterThanOrEqualTo('created_at','2015-03-12').find()
data.then((result) => {
// result contains the data of entries where the
//'created_at' date will be greaterThan or equalto '2015-06-22'
}).catch((error) => {
// error trace
})
include(key) → {this}
Includes references of provided fields of the entries being scanned
Parameters:
Name |
Type |
Description |
key |
*
|
uid/uid's of the field |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example')
.entries()
.include(['authors','categories'])
.find()
includeContentType() → {this}
Includes the total number of entries returned in the response.
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example')
.entries()
.includeContentType()
.find()
.then((result) => {
// Expected result
{
entries: [
{
...,
},
],
content_type_uid: 'example',
locale: 'en-us',
content_type: {
..., // Content type example's schema
}
}
}).catch((error) => {
// error trace
})
includeCount() → {this}
Includes the total number of entries returned in the response.
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example')
.entries()
.includeCount()
.find()
includeReferences(depth) → {this}
Includes all references of the entries being scanned
Parameters:
Name |
Type |
Description |
depth |
number
|
Optional parameter. Use this to override the default reference depth/level i.e. 4 |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example')
.entries()
.includeReferences()
.find()
language(languageCode) → {this}
to retrive the result bsed on the specific locale.
Parameters:
Name |
Type |
Description |
languageCode |
String
|
Language to query on |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example')
.entries()
.language('fr-fr')
.find()
lessThan(key, value) → {this}
Retrieves entries in which the value of a field is lesser than the provided value
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
value |
*
|
Value used to match or compare |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.lessThan('created_at','2015-06-22').find()
data.then((result) => {
// result content the data who's 'created_at date'
// is less than '2015-06-22'
}).catch((error) => {
// error trace
})
lessThanOrEqualTo(key, value) → {this}
Retrieves entries in which the value of a field is lesser than or equal to the provided value.
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
value |
*
|
Value used to match or compare |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.lessThanOrEqualTo('created_at','2015-06-22').find()
data.then((result) => {
// result contain the data of entries where the
//'created_at' date will be less than or equalto '2015-06-22'.
}).catch((error) => {
// error trace
})
limit(limit) → {this}
Returns a specific number of entries based on the set limit
Parameters:
Name |
Type |
Description |
limit |
Number
|
maximum number of entries to be returned |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.limit(10).find()
data.then((result) => {
// result contains the limited number of entries
}).catch((error) => {
// error trace
})
notContainedIn(key, value) → {this}
Retrieve entries in which the value of a field does not match
with any of the provided array of values.
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
value |
Array
|
Array of values that are to be used to match or compare |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.notContainedIn('title', ['Demo', 'Welcome']).find()
data.then((result) => {
// 'result' contains the list of entries where value of the
//title field should not be either "Demo" or ‘Welcome’
}).catch((error) => {
// error trace
})
notEqualTo(key, value) → {this}
Retrieves entries in which the value for a field does not match the provided value.
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
value |
*
|
Value used to match or compare |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.notEqualTo('title','Demo').find()
data.then((result) => {
// ‘result’ contains the list of entries where value
// of the ‘title’ field will not be 'Demo'.
}).catch((error) => {
// error trace
})
notExists(key) → {this}
Retrieve entries if value of the field, mentioned in the condition, does not exists.
Parameters:
Name |
Type |
Description |
key |
String
|
uid of the field |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.notExists('featured').find()
data.then((result) => {
// result is the list of non-existing’featured’" data.
}).catch((error) => {
// error trace
})
only(result) → {this}
Similar to MongoDB projections. Accepts an array.
Only fields mentioned in the array would be returned in the result.
Parameters:
Name |
Type |
Description |
result |
Array
|
Array of field properties |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
const query = Stack.contentType('example').entries().only(['title','uid']).find()
query.then((result) => {
// ‘result’ contains a list of entries with field title and uid only
}).catch((error) => {
// error trace
})
or(queries) → {this}
Retrieves entries that satisfy at least one of the given conditions
Parameters:
Name |
Type |
Description |
queries |
object
|
array of Query objects or raw queries |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let Query1 = Stack.contentType('example').entries().equalTo('title', 'Demo').find()
let Query2 = Stack.contentType('example').entries().lessThan('comments', 10).find()
blogQuery.or(Query1, Query2).find()
query(userQuery) → {this}
Retrieve entries based on raw queries
Parameters:
Name |
Type |
Description |
userQuery |
object
|
RAW (JSON) queries |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('example').entries().query({"authors.name": "John Doe"}).find()
.then((result) => {
// returns entries, who's reference author's name equals "John Doe"
})
.catch((error) => {
// handle query errors
})
queryReferences(query) → {this}
Wrapper, that allows querying on the entry's references.
Parameters:
Name |
Type |
Description |
query |
Any
|
Query filter, to be applied on referenced result |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.contentType('blog')
.entries()
.includeRferences() // This would include all references of the content type
.queryReferences({"authors.name": "John Doe"})
.find()
referenceDepth(depth) → {this}
Use it along with .includeReferences()
Overrides the default reference depths defined for references - 2
i.e. If A -> B -> C -> D, so calling .includeReferences() on content type A,
would result in all references being resolved until its nested child reference D
Parameters:
Name |
Type |
Description |
depth |
number
|
Level of nested references to be fetched |
- Deprecated:
- Source:
Returns:
- Returns the `stack's` instance
-
Type
-
this
Example
Stack.contentType('blog')
.entries()
.includeReferences()
.referenceDepth(4)
.find()
regex(key, value, optionsopt) → {this}
Retrieve entries that match the provided regular expressions
Parameters:
Name |
Type |
Attributes |
Description |
key |
String
|
|
uid of the field |
value |
*
|
|
value used to match or compare |
options |
String
|
<optional>
|
match or compare value in entry |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
blogQuery.regex('title','^Demo').find() //regex without options
//or
blogQuery.regex('title','^Demo', 'i').find() //regex without options
schema(uid) → {this}
Get a single content type's schema
Parameters:
Name |
Type |
Description |
uid |
String
|
Optional 'uid' of the content type, who's schema is to be fetched |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.schema(uid?: string).find()
schemas() → {this}
Get content type schemas
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
Stack.schemas().find()
skip(skip) → {this}
Skips at specific number of entries.
Parameters:
Name |
Type |
Description |
skip |
Number
|
number of entries to be skipped |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.skip(5).find()
data.then((result) => {
//result
}).catch((error) => {
// error trace
})
Retrieves entries based on the provided tags
Parameters:
Name |
Type |
Description |
values |
Array
|
Entries/Assets that have the specified tags |
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
const query = Stack.contentType('example').entries().tags(['technology', 'business']).find()
query.then((result) => {
// ‘result’ contains list of entries which have tags "’technology’" and ‘"business’".
}).catch((error) => {
// error trace
})
where(field, value) → {this}
Pass JS expression or a full function to the query system
Evaluate js expressions
Parameters:
Name |
Type |
Description |
field |
|
|
value |
|
|
- Source:
Returns:
- Returns `stack's` instance
-
Type
-
this
Example
const query = Stack.contentType('example').entries().where("this.title === 'Amazon_Echo_Black'").find()
query.then((result) => {
// ‘result’ contains the list of entries where value of
//‘title’ is equal to ‘Demo’.
}).catch(error) => {
// error trace
})