方法
fetch(id) → {Promise|GraphModel}
根据 ID 获取商店中的单个集合,不包括产品。要获取包含产品的集合,请使用 fetchWithProducts。
参数
名称 | 类型 | 描述 |
---|---|---|
id |
字符串 | 要获取的集合的 ID。 |
返回值
一个 promise,它解析为集合的 GraphModel
。
- 类型
- Promise | GraphModel
示例
client.collection.fetch('Xk9lM2JkNzFmNzIQ4NTIY4ZDFiZTUyZTUwNTE2MDNhZjg==').then((collection) => {
// Do something with the collection
});
fetchAll() → {Promise|Array.<GraphModel>}
获取商店中的所有集合,不包括产品。要获取包含产品的集合,请使用 fetchAllsWithProducts。
返回值
一个 promise,它解析为集合的 GraphModel
数组。
- 类型
- Promise | Array.<GraphModel>
示例
client.collection.fetchAll().then((collections) => {
// Do something with the collections
});
fetchAllWithProducts() → {Promise|Array.<GraphModel>}
获取商店中的所有集合,包括产品。
返回值
一个 promise,它解析为集合的 GraphModel
数组。
- 类型
- Promise | Array.<GraphModel>
示例
client.collection.fetchAllWithProducts().then((collections) => {
// Do something with the collections
});
fetchByHandle(handle) → {Promise|GraphModel}
根据 handle 获取商店中的集合。
参数
名称 | 类型 | 描述 |
---|---|---|
handle |
字符串 | 要获取的集合的 handle。 |
返回值
一个 promise,它解析为集合的 GraphModel
。
- 类型
- Promise | GraphModel
示例
client.collection.fetchByHandle('my-collection').then((collection) => {
// Do something with the collection
});
fetchQuery(argsopt) → {Promise|Array.<GraphModel>}
获取商店中与查询匹配的所有集合。
参数
名称 | 类型 | 属性 | 描述 | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
对象 | <可选> |
一个指定查询数据的对象,包含零个或多个 属性
|
返回值
一个 promise,它解析为集合的 GraphModel
数组。
- 类型
- Promise | Array.<GraphModel>
示例
client.collection.fetchQuery({first: 20, sortKey: 'CREATED_AT', reverse: true}).then((collections) => {
// Do something with the first 10 collections sorted by title in ascending order
});
fetchWithProducts(id) → {Promise|GraphModel}
根据 ID 获取商店中的单个集合,包括产品。
参数
名称 | 类型 | 描述 |
---|---|---|
id |
字符串 | 要获取的集合的 ID。 |
返回值
一个 promise,它解析为集合的 GraphModel
。
- 类型
- Promise | GraphModel
示例
client.collection.fetchWithProducts('Xk9lM2JkNzFmNzIQ4NTIY4ZDFiZTUyZTUwNTE2MDNhZjg==').then((collection) => {
// Do something with the collection
});