Page 3 of 3

Saving a database list into a local variable.

Posted: Tue Nov 12, 2013 12:18 am
by maxkatz

What exact data and in what order do you want it to be sorted?


Saving a database list into a local variable.

Posted: Tue Nov 12, 2013 12:35 am
by Christopher Herold

Like in the database. I want it to come out as 'name', 'email', 'phone', 'notes'. I don't need any of the other columns.


Saving a database list into a local variable.

Posted: Tue Nov 12, 2013 1:50 am
by maxkatz

There is no option yet to specify which columns you want via REST API. You will get all the columns and you can decide which to display on the page.

I'm going to check how to do this via Server Code.


Saving a database list into a local variable.

Posted: Wed Nov 13, 2013 4:02 am
by maxkatz

Here is how you can do it via Server Code:

resObject = Collection.retrieveObject(databaseId, collectionName, objectId, null);

response.success({
firstName: resObject.firstName,
lastName: resObject.lastName
});

Or use underscore’s pick (http://underscorejs.org/#pick) like this:
response.success(_.pick(dbObj, ‘firstName’, ‘lastName’));

Or you can delete items (columns) from the resulting array that you don't want to send to the client:

delete item.name;