Page 1 of 1

Block the create service when there is the same information you're trying to create

Posted: Sat Mar 07, 2015 8:50 am
by Mark Wong

For example, if I have a list of names which get from the user collection, and when I click on the list item, then it will create a new row with the current user name and the name on the list item in another collection.
What I want to achieve is if there is already a row with your user name and your target name, then you cannot create a new one anymore,
How should I do that?


Block the create service when there is the same information you're trying to create

Posted: Sat Mar 07, 2015 11:06 am
by Alena Prykhodko

Here is a brief plan:

When create item you should:

  1. Query db collection whether record already exists.
  2. If yes - you return error and do not execute create service.
  3. If not - you run create service .

Block the create service when there is the same information you're trying to create

Posted: Sat Mar 07, 2015 3:18 pm
by Mark Wong

How do I set the query service to check whether did anything return?
Because whatever the where query is, the status is still 200 ok.
So I can't set the create service execute when error, because everytime is success


Block the create service when there is the same information you're trying to create

Posted: Mon Mar 09, 2015 2:59 am
by Mark Wong

I've use the response to map the hidden label and compare the value,
Answered!


Block the create service when there is the same information you're trying to create

Posted: Mon Mar 09, 2015 3:31 am
by Yurii Orishchuk

Hi Mark,

Thanks for this update.

Regards.