-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃殌 Feature: The ability to upsert
documents
#3502
Comments
A temporary and not so optimal solution for flutter users: final database = Databases(client, databaseId: databaseId);
await database.upsert(collectionId: '', documentId: '', data: {}); Via this package: dependencies:
appwrite_extensions: ^0.0.1 Note This is merely syntactic sugar for checking if a document exists, if not, insert it, otherwise update it. But doesn't address the real concern of performance or reducing roundtrips etc. |
I would be grateful for this feature to be integrated into the core too. In many use cases it is irrelevant to the client whether the record needs to be created for the first time or simply updated; but at present, clients must manage whether certain documents have been inserted already or not, which can become tedious. Thx. |
+1 |
Thank you for raising this issue! 馃檹 We鈥檒l dig into this and get back to you as soon as we can. 馃槉 |
When attempting to insert a new Document; the Exception with message Same goes for the Only workaround I could think of is to do something like: let promises = [];
let update_promises = [];
console.time("insertdocuments");
for (let i = 0; i < documents.length; i++) {
let createdDocument = database.createDocument(databaseID, collectionID, documents[i][pk_Columns[collectionID]].toString(), documents[i]);
promises.push(createdDocument);
}
Promise.allSettled(promises)
.then((values) => {
for (let i = 0; i < values.length; i++) {
if(values[i].status == 'rejected' && values[i].reason.code == 409){
let updateDocument = database.updateDocument(databaseID, collectionID, documents[i][pk_Columns[collectionID]].toString(), documents[i]);
update_promises.push(updateDocument);
}
}
})
.then(() => {
Promise.allSettled(update_promises)
.then((values) => {
console.timeEnd("insertdocuments");
}
);
}
); |
more than one years still no update馃槬 |
Still waiting for resolvement of that issue. It's quire critical for IP telephony cause you need to rapidly update call status by webhook subscription. Right now it throws a lot of exceptions on create/update switch so logs are ugly |
馃憖 |
+1 for requesting this feature |
馃敄 Feature description
The ability to
upsert
documents. That is when performing an update, to insert it if it does not already exist.It was explained that it's not so common but at least for me that existed coming from Firebase, and a few rest API's that supported mongoDB. Regardless of this, it's still far more economic to perform an upsert operation than to check existence by hand before deciding upon a
create
orupdate
.馃帳 Pitch
Overall, it's just far more economic to have the option to upsert a document. Saves on roundtrips, saves on code, saves on time, saves on the client doing work.
There's two ways an SDK could implement it (using dart as an example).
Or...
馃憖 Have you spent some time to check if this issue has been raised before?
馃彚 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: