mirror of
https://github.com/fluxscape/fluxscape.git
synced 2026-01-10 14:22:53 +01:00
feat(runtime): Add "keys" and "excludeKeys" to fetch record api (#79)
Adding support for some more options when fetching a record.
91f9aca25b/src/Routers/ClassesRouter.js (L60-L68)
This commit is contained in:
@@ -263,7 +263,9 @@ class CloudStore {
|
||||
* @param {{
|
||||
* objectId: string;
|
||||
* collection: string;
|
||||
* keys?: string[] | string;
|
||||
* include?: string[] | string;
|
||||
* excludeKeys?: string[] | string;
|
||||
* success: (data: unknown) => void;
|
||||
* error: (error: unknown) => void;
|
||||
* }} options
|
||||
@@ -275,6 +277,16 @@ class CloudStore {
|
||||
args.push('include=' + (Array.isArray(options.include) ? options.include.join(',') : options.include));
|
||||
}
|
||||
|
||||
if (options.keys) {
|
||||
args.push('keys=' + (Array.isArray(options.keys) ? options.keys.join(',') : options.keys));
|
||||
}
|
||||
|
||||
if (options.excludeKeys) {
|
||||
args.push(
|
||||
'excludeKeys=' + (Array.isArray(options.excludeKeys) ? options.excludeKeys.join(',') : options.excludeKeys)
|
||||
);
|
||||
}
|
||||
|
||||
this._makeRequest(
|
||||
'/classes/' + options.collection + '/' + options.objectId + (args.length > 0 ? '?' + args.join('&') : ''),
|
||||
{
|
||||
|
||||
@@ -112,7 +112,9 @@ function createRecordsAPI(modelScope) {
|
||||
* @param {string | { getId(): string; }} objectOrId
|
||||
* @param {{
|
||||
* className: string;
|
||||
* keys?: string[] | string;
|
||||
* include?: string[] | string;
|
||||
* excludeKeys?: string[] | string;
|
||||
* }} options
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
@@ -129,7 +131,9 @@ function createRecordsAPI(modelScope) {
|
||||
cloudstore().fetch({
|
||||
collection: className,
|
||||
objectId: objectOrId,
|
||||
include: options ? options.include : undefined,
|
||||
keys: options?.keys,
|
||||
include: options?.include,
|
||||
excludeKeys: options?.excludeKeys,
|
||||
success: function (response) {
|
||||
const record = cloudstore()._fromJSON(response, className);
|
||||
resolve(record);
|
||||
|
||||
@@ -227,6 +227,9 @@ declare namespace Noodl {
|
||||
objectOrId: string | { getId(): string; },
|
||||
options?: {
|
||||
className?: RecordClassName;
|
||||
keys?: string[] | string;
|
||||
include?: string[] | string;
|
||||
excludeKeys?: string[] | string;
|
||||
}
|
||||
): Promise<any>;
|
||||
|
||||
|
||||
@@ -274,6 +274,9 @@ declare namespace Noodl {
|
||||
objectOrId: string | { getId(): string; },
|
||||
options?: {
|
||||
className?: RecordClassName;
|
||||
keys?: string[] | string;
|
||||
include?: string[] | string;
|
||||
excludeKeys?: string[] | string;
|
||||
}
|
||||
): Promise<any>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user