Page 1 of 1

Writing the user object (pointer) back to another collection

Posted: Tue Jul 08, 2014 3:43 pm
by Terry Gilliver

I have a shopping cart which consists accesses 4 db collections, Users, Orders, LineItems and ProductItems.

The Order collection looks like this:
Image

The LineItems collections looks like this:
Image

and the productItems collection looks like this:
Image

I have a mapping for my create order service (which writes to the order collection as follows:
Image

I am getting an error because I am passing a string for the userid instead of the user collection. Can you advise how to do this?


Writing the user object (pointer) back to another collection

Posted: Tue Jul 08, 2014 4:23 pm
by Evgene Karachevtsev

Hello Terry,

In a column of type pointer you should pass not the line but json.
Please add in mapping to request parameter CustomerId this js code

codereturn {"collName":"_users", "explained":value};/code


Writing the user object (pointer) back to another collection

Posted: Tue Jul 08, 2014 6:23 pm
by Terry Gilliver

var id = localStorage.getItem("userid");
return {"collName" : "users", "id" : id};

worked a treat, Thanks