Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed sharing dataset 500 error #468

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/datasets/datasets.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,12 +924,13 @@ export class DatasetsController {
description: "Id of the dataset to be modified",
type: String,
})
@ApiParam({
@ApiQuery({
name: "fieldName",
description: "Name of the field to be updated",
type: String,
})
@ApiBody({
@ApiQuery({
nitrosx marked this conversation as resolved.
Show resolved Hide resolved
name: "data",
description: "Json object with the fields to be updated and their values",
required: true,
type: Array,
Expand All @@ -942,13 +943,16 @@ export class DatasetsController {
async appendToArrayField(
@Param("pid") id: string,
@Query("fieldName") fieldName: string,
@Body() data: unknown[],
@Query("data") data: string,
): Promise<DatasetClass | null> {
// $addToSet is necessary to append to the field and not overwrite
// $each is necessary as data is an array of values

const parsedData = JSON.parse(data);

const updateQuery: UpdateQuery<DatasetDocument> = {
$addToSet: {
[fieldName]: { $each: data },
[fieldName]: { $each: parsedData },
},
};

Expand Down