strongloop / loopback-example-offline-sync

Offline sync, change tracking, and replication.
http://loopback.io/doc/en/lb2/Synchronization.html
Other
286 stars 110 forks source link

Todo Edit - sync with MongoDB - gives E11000 duplicate key error index #59

Closed anupsaund closed 9 years ago

anupsaund commented 9 years ago

Issue Overview

I forked the loopback-example-full-stack and then created a datasource for mongoDB - mongo version 3.0.1. Then i changed the todo model to use mongodb as a datasource.

Creating and deleting a todo works OK - but if I try to edit a Todo I get a duplicate key error;

MongoError: E11000 duplicate key error index: test.Todo.$id dup key: { : "t-2159" }

Forked at

https://github.com/anupsaund/loopback-example-full-stack

One commit

https://github.com/anupsaund/loopback-example-full-stack/commit/a8ea1a4f68bda75cbfc5dd0426d21a1a0f715029

Screenshot

todoedit

superkhau commented 9 years ago

Did you try clearing out your database? I've confirmed the edit feature is not working properly, but I can't reproduce your duplicate id issue

@bajtos When I edit any todo, the changes are not reflected in the database. Create and delete are working properly. Ideas?

anupsaund commented 9 years ago

@superkhau

I have tried a fresh test, and then tried to show the story in the following screenshots.

1. Clear mongo table and app

empty_table_empty_todo_list

2. Record Added

record_added

3. Record Edited

test_edited

bajtos commented 9 years ago

This is most likely a bug in the replication algorithm that have been fixed on loopback master. We should verify after a new version of the following modules was released: loopback, loopback-datasource-juggler, loopback-connector-mongodb. See https://github.com/strongloop/loopback/issues/1167.

anupsaund commented 9 years ago

@bajtos - I implemented the code change from https://github.com/strongloop/loopback/pull/973

It fixed the errors.

superkhau commented 9 years ago

These errors should be fixed on master with my latest updates. Closing.