Page 1 of 1

How to do something if an item does not exist in collection

Posted: Sun Feb 09, 2014 3:43 pm
by Tom6106181

Hi.

I have a collection of items.

  • users are able to save item to favorites (localstorage).

  • users are able to remove items from favorites (lets call it function delFav(id))

    If another user, who owns the item in question (that the user have set as favorite), deletes his item, the user will get a error message when trying to read/view the item.
    code
    Object {code: "DBSG205", description: "Collection 'items' doesn't contain object with id 52f0b8dbe4b00fc15f845051."}
    /code

    Now to my question, how can I perform a check when the item is not found in collection, and ask the user if he would also like to remove it from his favorites?

    I can not find anywhere what type of response the DB will give me if READ:

  • Item ID is not found in collection

  • User has no internet access (will the read service give similar error)

  • Something else went wrong.

    I only want to ask the user, when item id is NOT found in collection (eg, ReadService is invoked, and return error, not found in collection).

    I do not want to ask the user to remove from favorites if unable to read for some other reason (missing internet connection or similar).

    Any suggestions how to ask user if he would like to call function delFav(id) if not found in collection?

    Thanks!
    -Tom


How to do something if an item does not exist in collection

Posted: Sun Feb 09, 2014 4:05 pm
by Alena Prykhodko

Hello Tom,

If you read from DB it's GET request.
Here is how to make a query to the collection http://docs.appery.io/documentation/b...
Then you can use Service callbacks http://docs.appery.io/documentation/r... to call function.


How to do something if an item does not exist in collection

Posted: Sun Feb 09, 2014 6:48 pm
by Tom6106181

Yes I know how to do it, but I do not know what response the DB will give me on error; not found in collection vs. unable to connect to db.

Could you please point me to error codes in use?
Can not find it anywhere in the docs.

ex: If not not found in collection = error code =
ex: if unable to connect to DB = error code =
and so on.......


How to do something if an item does not exist in collection

Posted: Mon Feb 10, 2014 9:12 pm
by Kateryna Grynko

Hi Tom,

You can find a list of error codes here:
http://docs.appery.io/documentation/c...