maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Saving a database list into a local variable.

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

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Saving a database list into a local variable.

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Saving a database list into a local variable.

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.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Saving a database list into a local variable.

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;

Return to “Issues”