Start a new topic

Select distinct

Hello,



Is it possible to make a "select distinct(column)" using your data store ?

(the features in MongoDB : http://docs.mongodb.org/manual/reference/method/db.collection.distinct/)



Thank you.

Hi,


This is the endpoint code for a distinct by user :

 

function onRequest(request, response, modules) {
  var userId=modules.requestContext.getAuthenticatedUserId();
  var aclQuery = {"_acl":{"creator":userId}};
  
 modules.collectionAccess.collection(request.body.collectionName).distinct(request.body.columnName, aclQuery, function (err, docs) {
  if (err) {
    modules.logger.error('Query failed: '+ err);
  } else {
    response.body = docs;
    response.complete(200);
  }
});
}

 

Why not including the "select distinct" feature in the standard API ?
Thanks a lot !
Hello Fabreax,



This is the type of thing that business logic is often used for. You can check out CollectionAccess here: http://devcenter.kinvey.com/html5/reference/business-logic/reference.html#collection-access-module Which is very likely what you are looking for.



Please let me know if you have any other questions,
Login or Signup to post a comment