-4

I'm using Deployd with Swift iOS. All I'm saving is two text strings. I just want to prevent duplicate entries.

halfer
  • 19,824
  • 17
  • 99
  • 186
Codetard
  • 2,441
  • 28
  • 34
  • 2
    Your downvotes were likely due to the brevity of this post, plus the use of "ASAP", which sounds demanding. The volunteers here will answer questions at their leisure. – halfer Sep 10 '15 at 15:48

1 Answers1

2

This is how I'm checking if an element exists, to implement this just open the Deployd's dasboard choose your collection paste this snippet to POST section. Just dont forget to put your collection's name in the place of YOUR_COLLECTION_NAME. enjoy.!

var query=this; 
delete query.id;
    var resultAr = []; dpd.YOUR_COLLECTION_NAME.get(query ,function(result){
                        if (result) {
                            resultAr = result;
                            if (resultAr.length === 0){
                                emit ("success");
                             }
                            else {
                                error("same entry already exist", 400);
                            }
                        } });
Codetard
  • 2,441
  • 28
  • 34