We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
It would be amazing to be able to perform deletes and updates based on where conditions instead of just by ID's.
Here are 2 functions I created for the HttpClient, it would be really powerful to have this available on both the Triplit client and the HttpClient.
import type { CollectionNameFromModels, HttpClient, Models, UpdatePayload, WhereFilter } from "@triplit/client" export async function deleteWhere<M extends Models<M> = Models>( httpClient: HttpClient<M>, collectionName: CollectionNameFromModels<M>, where: WhereFilter<M, CollectionNameFromModels<M>>[], batchSize = 500 ) { let total = 0 while (true) { const entities = (await httpClient.fetch({ collectionName, where, limit: batchSize })) as unknown as { id: string }[] await Promise.all(entities.map((entity) => httpClient.delete(collectionName, entity.id))) total += entities.length if (entities.length < batchSize) break } return total } export async function updateWhere<M extends Models<M> = Models>( httpClient: HttpClient<M>, collectionName: CollectionNameFromModels<M>, where: WhereFilter<M, CollectionNameFromModels<M>>[], update: UpdatePayload<M, CollectionNameFromModels<M>>, batchSize = 500 ) { let total = 0 while (true) { const entities = (await httpClient.fetch({ collectionName, where, limit: batchSize })) as unknown as { id: string }[] await Promise.all( entities.map((entity) => httpClient.update(collectionName, entity.id, update)) ) total += entities.length if (entities.length < batchSize) break } return total }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
It would be amazing to be able to perform deletes and updates based on where conditions instead of just by ID's.
Here are 2 functions I created for the HttpClient, it would be really powerful to have this available on both the Triplit client and the HttpClient.
The text was updated successfully, but these errors were encountered: