Start a new topic

Unable to delete record by record in collection by removeById on different device


I just stumbled over situation where I can't delete a record in a collection by using "removeById". In short: A customer can create a textual log entry which will be stored in a collection. He can see his note entry and therefore update or delete it. That all works fine. But when the same user logs in to another device (with same credentials) and tries to delete his note entry I got this error message in the Browser console:

code: 404

debug: undefined

kinveyRequestId: undefined

message: "An entity with _id = 5d4dbea061276e3b4b57756c was not found in the gamelogs collection on the kid_<xxxxxxxxx> database."

name: "NotFoundError"

stack: "o@https://www.myServerUrl/app/js/kinvey-html5-sdk-3.12.2.min.js:8:24369…"

In other words:

1. User A logs in on device 1 and creates a textual note C that will be stored in a collection (_id created by Kinvey backend). User A could delete now is log entry in the collection and will not run into the error shown above. The record would be deleted correctly in the collection, all fine.

2. User A logs in to device 2 (with same credentials as before on device 1) and tries to delete note C -> error message shown above.

The keypoint is that the same user (same credentials) are used on 2 different devices.

One weird thing I found out to avoid the error: User A on device 2 could first do an update on his note C (which would be updated correctly, no error) and THEN delete note C. -> User A would not run into the error just by the fact he first updates the note C before he deletes it!

The delete skeleton I'm using:   

var noteLogStore = Kinvey.DataStore.collection('myCollection');

    .then(function onSuccess(result) {
        console.log ('success');
    .catch(function onError(error) {
        console.log (logId);
        console.log (error);    // showing the error message posted above

The logId is the unique _id of the note entry (automatically created by Kinvey backend on creating the log entry in myCollection) that I read in a previous step in order to show/display the log.

In the described error case it jumps into the "catch" area and does also output the logId which is the complete and valid _id of the record (I can do a search by this in the Kinvey Console and the correct note record will be found).

To be complete:

I haven't changed any permissions for that user, meaning "All Users" role are considered but even giving the user the maximum permission ("always" on all 4 operations) will still lead into the same error message.

I also have Business Logic on the affected collection but it's on "PostSave" and will not be triggered by the operation "removeById". I have even removed the Business Logic temporarily to be absolutely sure it won't be triggered and won't affect the error -> confirmed.

Any ideas why this could happen or how the error could be avoided?


I recently found out that deleting isn't possible anymore on the same device if you logout/login in between.

I've found a solution that seems to work in every situation:

var query = new Kinvey.Query();
query.equalTo('_id', logId);
var promise = gameLogStore.remove(query);

promise.then(function onSuccess(result) {
     console.log ('deleted');
}).catch(function onError(error) {
     console.log (error);

Login or Signup to post a comment