pocketbase / pocketbase

Open Source realtime backend in 1 file
https://pocketbase.io
MIT License
40.76k stars 1.91k forks source link

update record with a WHERE statement #549

Closed mcmuchenje closed 2 years ago

mcmuchenje commented 2 years ago

Trying to update a record in a collection where i match a field which is not the RECORD_ID

not sure if this is possible is the javascript-sdk

Kindly requesting help

Big fan of the project by the way

ganigeorgiev commented 2 years ago

You can update a record only by its ID.

If you want to perform update ussing a different field, you can query first the record and then extract its id and send it in the update request.

In future we will add support for bulk update/create/delete which will allow providing a filter query, but that will be after the users and profiles refactoring (you could also check this discussion - https://github.com/pocketbase/pocketbase/discussions/545).

hood commented 2 years ago

This should not be marked as complete IMHO. Keeping it open makes sense in this case.

ganigeorgiev commented 2 years ago

@hood bulk update/create/delete will be handled together with the data import feature. You could subscribe to issue #48.

0x1337z commented 5 months ago

is this implemented yet?

ganigeorgiev commented 5 months ago

@0x1337z If you are asking for updating a record using a WHERE/filter clause with the Web APIs, then No and there are no longer plans for this as it comes with too many edge cases. If you really need it you'll have to register your own route and operate with db helpers (using Go or the JSVM).

If you are asking for the bulk update/create/delete actions, then this is already implemented as part of the ongoing refactoring but again the individual operation would be similar to the existing APIs, aka. they require to provide the id of the record to update/delete.