mirror of
https://github.com/fluxscape/fluxscape.git
synced 2026-01-11 06:42:56 +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 {{
|
* @param {{
|
||||||
* objectId: string;
|
* objectId: string;
|
||||||
* collection: string;
|
* collection: string;
|
||||||
|
* keys?: string[] | string;
|
||||||
* include?: string[] | string;
|
* include?: string[] | string;
|
||||||
|
* excludeKeys?: string[] | string;
|
||||||
* success: (data: unknown) => void;
|
* success: (data: unknown) => void;
|
||||||
* error: (error: unknown) => void;
|
* error: (error: unknown) => void;
|
||||||
* }} options
|
* }} options
|
||||||
@@ -275,6 +277,16 @@ class CloudStore {
|
|||||||
args.push('include=' + (Array.isArray(options.include) ? options.include.join(',') : options.include));
|
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(
|
this._makeRequest(
|
||||||
'/classes/' + options.collection + '/' + options.objectId + (args.length > 0 ? '?' + args.join('&') : ''),
|
'/classes/' + options.collection + '/' + options.objectId + (args.length > 0 ? '?' + args.join('&') : ''),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -112,7 +112,9 @@ function createRecordsAPI(modelScope) {
|
|||||||
* @param {string | { getId(): string; }} objectOrId
|
* @param {string | { getId(): string; }} objectOrId
|
||||||
* @param {{
|
* @param {{
|
||||||
* className: string;
|
* className: string;
|
||||||
|
* keys?: string[] | string;
|
||||||
* include?: string[] | string;
|
* include?: string[] | string;
|
||||||
|
* excludeKeys?: string[] | string;
|
||||||
* }} options
|
* }} options
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
@@ -129,7 +131,9 @@ function createRecordsAPI(modelScope) {
|
|||||||
cloudstore().fetch({
|
cloudstore().fetch({
|
||||||
collection: className,
|
collection: className,
|
||||||
objectId: objectOrId,
|
objectId: objectOrId,
|
||||||
include: options ? options.include : undefined,
|
keys: options?.keys,
|
||||||
|
include: options?.include,
|
||||||
|
excludeKeys: options?.excludeKeys,
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
const record = cloudstore()._fromJSON(response, className);
|
const record = cloudstore()._fromJSON(response, className);
|
||||||
resolve(record);
|
resolve(record);
|
||||||
|
|||||||
@@ -227,6 +227,9 @@ declare namespace Noodl {
|
|||||||
objectOrId: string | { getId(): string; },
|
objectOrId: string | { getId(): string; },
|
||||||
options?: {
|
options?: {
|
||||||
className?: RecordClassName;
|
className?: RecordClassName;
|
||||||
|
keys?: string[] | string;
|
||||||
|
include?: string[] | string;
|
||||||
|
excludeKeys?: string[] | string;
|
||||||
}
|
}
|
||||||
): Promise<any>;
|
): Promise<any>;
|
||||||
|
|
||||||
|
|||||||
@@ -274,6 +274,9 @@ declare namespace Noodl {
|
|||||||
objectOrId: string | { getId(): string; },
|
objectOrId: string | { getId(): string; },
|
||||||
options?: {
|
options?: {
|
||||||
className?: RecordClassName;
|
className?: RecordClassName;
|
||||||
|
keys?: string[] | string;
|
||||||
|
include?: string[] | string;
|
||||||
|
excludeKeys?: string[] | string;
|
||||||
}
|
}
|
||||||
): Promise<any>;
|
): Promise<any>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user