Create data again and again

2 posts, 0 answers
  1. Calebe
    Calebe avatar
    1 posts
    Member since:
    Sep 2014

    Posted 06 Jan 2016 Link to this post

    I have tried to create an row on Backend Service after I have created another. I do not intend to create multiple, but let the user create repeatedly. To do the the button on NativeScript/Everlive calls this function.

     But, after first time, Everlive shows this error: The operation results in a duplicate key for a unique index. code 107

    exports.addMed = function(args) {
        med.isLoading = true;
        data.create(medidas.registros, function(data) {
            med.isLoading = false;
        }, function(data) {
            med.isLoading = false;

  2. Martin
    Martin avatar
    103 posts

    Posted 08 Jan 2016 Link to this post

    Hi Calebe,

    The “duplicate key for a unique index” message with error code 107 is returned from the server when the request is trying to add an item with an Id while there is an item with the same Id in the database. This is due to the fact that the Id field must be unique. To solve this consider either:

    1.       Do not enter an Id when creating the item(s). The Id will be populated automatically by the system.

    2.       If you want to have your own custom ID for each item, make sure each one is unique.

    Let me know if this helps.

    Best regards,

    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
Back to Top