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

updateOne and updateMany Response fields #168

Closed
kathirsvn opened this issue Feb 22, 2023 · 4 comments
Closed

updateOne and updateMany Response fields #168

kathirsvn opened this issue Feb 22, 2023 · 4 comments
Assignees

Comments

@kathirsvn
Copy link
Contributor

kathirsvn commented Feb 22, 2023

Currently, updateOne and updateMany Response fields are missing some of the counts required.

Here's a sample response:
{"status":{"updatedIds":["7505ffec-47a0-4346-8ee3-72fd70ad09e5"]}}

But it's supposed to have below fields:

Field Description
matchedCount updateOne - always 1 in the case of updateOne and a document is found for the given filter
updateMany - its the number of docs that matched the criteria
modifiedCount updateOne - 1 in the case when a document is found and the modification is applied and 0 if any modification was not needed/applied
updateMany - Number of docs the modification has been applied on.
upsertedId When the upsert option is present and set to true in the request and no doc is found for the given filter and a new doc is inserted -the _id of the new doc inserted

When either the upsert option is not present in the request or if it's set to false, this field should not be included in the response or undefined in other words.

This is applicable for both updateOne and updateMany

Aaron Morton - Please use the description of the response data in the specification, not the table above https://github.com/stargate/jsonapi/blob/main/docs/jsonapi-spec.textile#commands

@maheshrajamani
Copy link
Contributor

@kathirsvn @amorton Can you confirm on the upsertedId? I thought we discussed this field to have document id if we created a new document, because upsert flag set to true in request and no document found in DB for the given filter condition.

@maheshrajamani
Copy link
Contributor

updateMany - its the number of docs that matched the criteria

@amorton Does this count going to be number of records read from the database based on the filter, if limit is 20 we read max of 20 records. If we need documents for the matched criteria we need to run count query separately.

@kathirsvn
Copy link
Contributor Author

@kathirsvn @amorton Can you confirm on the upsertedId? I thought we discussed this field to have document id if we created a new document, because upsert flag set to true in request and no document found in DB for the given filter condition.

@maheshrajamani yes you are correct. Let me fix the description of upsertedId.

@amorton
Copy link
Contributor

amorton commented Feb 23, 2023

I have added a note to the description that the source of truth is the API spec, all commands now how a response section see https://github.com/stargate/jsonapi/blob/main/docs/jsonapi-spec.textile#commands

@amorton Does this count going to be number of records read from the database based on the filter, if limit is 20 we read max of 20 records. If we need documents for the matched criteria we need to run count query separately.

@maheshrajamani It will always be the number of rows we read from the filter including the limit, we will not nun a seperate query to get the total. If this is not clear in the spec let me know https://github.com/stargate/jsonapi/blob/main/docs/jsonapi-spec.textile#commands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants