Skip to content

Commit

Permalink
WIP addAssets
Browse files Browse the repository at this point in the history
  • Loading branch information
sebtiz13 committed Jun 2, 2023
1 parent d7b6dc4 commit e943ed6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
16 changes: 9 additions & 7 deletions lib/modules/asset/AssetsGroupsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,15 @@ export class AssetsGroupsController {
_id
);

// TODO implement addAsset on database
// eslint-disable-next-line no-console
console.debug({
_id,
action: request.getAction(),
body,
return await this.sdk.document.mUpdate(
engineId,
});
InternalCollection.ASSETS,
body.assetId.map((assetId) => ({
_id: assetId,
body: {
group: _id,
},
}))
);
}
}
4 changes: 4 additions & 0 deletions lib/modules/asset/collections/assetsMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export const assetsMappings = {
type: "keyword",
fields: { text: { type: "text" } },
},
group: {
type: "keyword",
fields: { text: { type: "text" } },
},

metadata: {
properties: {
Expand Down
10 changes: 8 additions & 2 deletions lib/modules/asset/types/AssetGroupsAPI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk";
import {
JSONObject,
KDocument,
KHit,
SearchResult,
mUpdateResponse,
} from "kuzzle-sdk";
import { AssetsGroupsBody, AssetsGroupContent } from "./AssetGroupContent";

// Make "parent" property to optionnal for request
Expand Down Expand Up @@ -57,4 +63,4 @@ export interface ApiGroupAddAssetsRequest extends GroupControllerRequest {
assetId: string[];
};
}
export type ApiGroupAddAssetsResult = void;
export type ApiGroupAddAssetsResult = mUpdateResponse;
1 change: 1 addition & 0 deletions tests/scenario/modules/assets/asset-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ describe("AssetsGroupsController", () => {
},
});

// TODO improve tests
expect({ error, status }).toStrictEqual({
error: null,
status: 200,
Expand Down

0 comments on commit e943ed6

Please sign in to comment.