Page 1 of 2
Read Database
Posted: Sat Jan 25, 2014 7:24 am
by Robert Larsen
Ok I call a service it returns an array of id's, that are relevant. I have a custom collection in my database that are populated with the exact same id's plus more columns with other information, but I need to only list the ones that the service and other factors have determined are relevant. Well actually I don't need to list the Id's but I need to list the other columns of data associated with those id's. How can I call my database and read these other columns associated with my id's. EX. My column is EventId: with string 4544 and its related column EventName: with string Robert. So I have called my api I know that the EventID: is 4544 so now I need to read my database and find EventId: 4544 but list EventName: Robert in my service mapping. How do I do this without using the assigned ObjectId in the database, because the api I call does not know the automatically generated ObjectId? And at the same time im not just calling one object but an entire array of these id's.
inline.png?1390634636[/img] [/url]
Read Database
Posted: Sat Jan 25, 2014 7:28 am
by Robert Larsen
Also one other thing, I did try mapping the EventId from API Rest Service to LSV then Added a Query service for my back-end. And mapped the LSV to the "where" Request on the Query service. But When I do this I only get one result in my list not the whole array.
Read Database
Posted: Sat Jan 25, 2014 9:34 am
by Robert Larsen
Read Database
Posted: Sat Jan 25, 2014 12:11 pm
by Illya Stepanov
Hi Robert -
Do you want to make query from your DataBase or from the service?
Read Database
Posted: Sat Jan 25, 2014 7:09 pm
by Robert Larsen
From the database, I'm not even sure that's the correct thing to be doing.
Read Database
Posted: Sun Jan 26, 2014 7:18 am
by Robert Larsen
Ok, I see my problem now. When I map my LSV to "Where" it is only passing the first key in the LSV String. What JS do I need to add to mapping on where? Also depending on other elements the LSV could have in between 1 and 16 keys. I have tried this code
return '{"EventId":"'+value+'"}';
And it only returns one result in my UI because I believe I am only picking up the one +value+. Is there anyway to pass all of the key values to the query and then have their data returned?
Read Database
Posted: Sun Jan 26, 2014 8:16 am
by Alena Prykhodko
Hello Robert,
Can you show the content of this when running:
pre
alert('{"EventId": ' + value + '}');/pre
Read Database
Posted: Sun Jan 26, 2014 8:31 am
by Robert Larsen
Read Database
Posted: Sun Jan 26, 2014 9:01 pm
by Robert Larsen
Any help would be appreciated.
Read Database
Posted: Mon Jan 27, 2014 9:04 am
by Maryna Brodina
Hello! Sorry for a late reply.
1) "When I map my LSV to "Where" it is only passing the first key in the LSV String. What JS do I need to add to mapping on where?" - could you clarify what do you mean on "first key in the LSV String"? What is stored in LSV?
2) On screenshot https://d2r1vs3d9006ap.cloudfront.net... you map event_id from response (response is array) to localStorage variable - it's not corrcet. Every new value will overwrite previous one. To make all event_id from response stored in event_id localStorage variable as array on service success event add the following code: prevar event_id = [];
data.forEach(function(elem){
event_id.push(elem["event_id"]);
});
localStorage.setItem("event_id", event_id);/pre