Is it possible to retrieve data of all classes in Parse using single REST URL request? - parse-platform

just a scenario :
I have 4 classes created in Parse cloud database for a particular Application - ClassA, ClassB, ClassC, ClassD.
I can retrieve data related to ClassA using REST URL like - https://api.parse.com/1/classes/ClassA
Is it possible to retrieve data of all 4 classes using single REST URL ?

No, it's not possible to do this. You can query from a single class at a time, and a maximum of 1,000 objects.
A cloud function can make multiple queries and merge the results, meaning that a single REST call (to call the function) could return results from multiple classes (but a maximum of 1,000 objects per query). Something like this:
Parse.Cloud.define("GetSomeData", function(request, response) {
var query1 = new Parse.Query("ClassA");
var query2 = new Parse.Query("ClassB");
query1.limit(1000);
query2.limit(1000);
var output = {};
query1.find().then(function(results) {
output['ClassA'] = results;
return query2.find();
}).then(function(results) {
output['ClassB'] = results;
response.success(output);
}, function(error) {
response.error(error);
});
});

Related

Getting Audit Record Details from Dynamics 365 to Power BI

I have been able to pull down an audit table from Dynamics 365 and load it into Power BI by selecting Get Data, choosing the odata option and using url/api/data/v9.1/audits. I see the column RetrieveAuditDetails, but I don't understand why all the values say Function. Is there a way to extend this to show the old value/new value in the same way you can change, for example, UserIDs to be extended to the full name?
When it comes to audit data, OData/Web API REST endpoint is not so friendly in PowerBI due to the reason that the audit data is stored as delimited values in database. Refer my answer in this SO thread.
If it's a javascript or .net application you can do iterative call using RetrieveAuditDetails function to fetch full details after getting full list using https://crmdev.crm.dynamics.com/api/data/v9.1/audits. This is why you are seeing as Function in there.
For example:
var parameters = {};
var entity = {};
entity.id = "5701259e-59b8-e911-bcd0-00155d0d4a79";
entity.entityType = "audit";
parameters.entity = entity;
var retrieveAuditDetailsRequest = {
entity: parameters.entity,
getMetadata: function() {
return {
boundParameter: "entity",
parameterTypes: {
"entity": {
"typeName": "mscrm.audit",
"structuralProperty": 5
}
},
operationType: 1,
operationName: "RetrieveAuditDetails"
};
}
};
Xrm.WebApi.online.execute(retrieveAuditDetailsRequest).then(
function success(result) {
if (result.ok) {
var results = JSON.parse(result.responseText);
}
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
Update:
On further analysis - there is no big difference between the output schema from the above RetrieveAuditDetails query targeting single auditid or the below filtered audits query targeting single recordid.
https://crmdev.crm.dynamics.com/api/data/v9.1/audits?$filter=_objectid_value eq 449d2fd8-58b8-e911-a839-000d3a315cfc
The fact is either web api or fetchxml, the resultset cannot fetch the important column changedata which contains the changed field values - due to the restriction: Retrieve can only return columns that are valid for read. Column : changedata. Entity : audit
I get this in FetchXML builder:
There is another approach but not PowerBI compatible anyway, using RetrieveRecordChangeHistory to target the recordid to get all the audit collections with old & new values. Example below:
https://crmdev.crm.dynamics.com/api/data/v9.0/RetrieveRecordChangeHistory(Target=#Target)?#Target={%22accountid%22:%22449d2fd8-58b8-e911-a839-000d3a315cfc%22,%22#odata.type%22:%22Microsoft.Dynamics.CRM.account%22}

How to execute Linq queries in Serenity

I have created an application using Serenity framework. I have completed basic functionality for CRUD using serenity. Based on my tables I need to have graphical representations, any charts like high charts, D3 charts or any .
1. How can I get data from the tables using Linq in serenity
Finally I have found the answer for this. We can use sql queries as well as stored procedure to fetch data from DB. I have used stored procedure and linq to get the data from db.
In repository page you can add Linq,
public ListResponse<MyRow> GetUsers(IDbConnection connection)
{
// This must be te Repository
var myRepos = new UserRepository();
// This must be a type of Request (in this case ListRequest)
var request = new ListRequest();
request.Take = 100;
// This must be a type of Response (in this case ListResponse)
var response = new ListResponse<MyRow>();
// This must be called on Repository
var result = myRepos.List(connection, request);
// Data
var data = result.Entities.Where(r => r.Name != "").ToList();
response.Entities = data;
return response;
}
I have already defined MyRow as UserRow like this using MyRow = Entities.UserRow;.
Hope this will help you.

Angular Meteor objects not acting as expected

I am working with Angular Meteor and am having an issue with my objects/arrays. I have this code:
angular.module("learn").controller("CurriculumDetailController", ['$scope', '$stateParams', '$meteor',
function($scope, $stateParams, $meteor){
$scope.curriculum = $meteor.object(CurriculumList, $stateParams.curriculumId);
$scope.resources = _.map($scope.curriculum.resources, function(obj) {
return ResourceList.findOne({_id:obj._id})
});
console.log($scope.resources)
}]);
I am attempting to iterate over 'resources', which is a nested array in the curriculum object, look up each value in the 'ResourceList' collection, and return the new array in the scope.
Problem is, sometimes it works, sometimes it doesnt. When I load up the page and access it through a UI-router link. I get the array as expected. But if the page is refreshed, $scope.resources is an empty array.
My thought is there is something going on with asynchronous calls but have not been able for find a solution. I still have the autopublish package installed. Any help would be appreciated.
What you're going to do is return a cursor containing all the information you want, then you can work with $meteor.object on the client side if you like. Normally, publishComposite would look something like this: (I don't know what your curriculum.resources looks like)
Use this method if the curriculum.resources has only ONE id:
// this takes the place of the publish method
Meteor.publishComposite('curriculum', function(id) {
return {
find: function() {
// Here you are getting the CurriculumList based on the id, or whatever you want
return CurriculumList.find({_id: id});
},
children: [
{
find: function(curr) {
// (curr) will be each of the CurriculumList's found from the parent query
// Normally you would do something like this:
return ResourceList.find(_id: curr.resources[0]._id);
}
}
]
}
})
This method if you have multiple resources:
However, since it looks like your curriculum is going to have a resources list with one or many objects with id's then we need to build the query before returning anything. Try something like:
// well use a function so we can send in an _id
Meteor.publishComposite('curriculum', function(id){
// we'll build our query before returning it.
var query = {
find: function() {
return CurriculumList.find({_id: id});
}
};
// now we'll fetch the curriculum so we can access the resources list
var curr = CurriculumList.find({_id: id}).fetch();
// this will pluck the ids from the resources and place them into an array
var rList = _.pluck(curr.resources, '_id');
// here we'll iterate over the resource ids and place a "find" object into the query.children array.
query.children = [];
_.each(rList, function(id) {
var childObj = {
find: function() {
return ResourceList.find({_id: id});
}
};
query.children.push(childObj)
})
return query;
});
So what should happen here (I didn't test) is with one publish function you will be getting the Curriculum you want, plus all of it's resourceslist children.
Now you will have access to these on the client side.
$scope.curriculum = $meteor.object(CurriculumList, $stateParams.curriculumId);
// collection if more than one, object if only one.
$scope.resources = $meteor.collection(ResoursesList, false);
This was thrown together somewhat quickly so I apologize if it doesn't work straight off, any trouble I'll help you fix.

How to get an entity in marionette.js using an existing backend service?

Suppose I have the following entity:
MyApp.module('Entities', function(Entities, MyApp, Backbone, Marionette, $, _) {
Entities.SomeEntity = Backbone.Model.extend({});
var API = {
getSomeEntity: function(someEntityId) {
// What goes here?
}
};
MyApp.reqres.setHandler("someEntity:entities", function(someEntityId) {
return API.getSomeEntity(someEntityId);
});
});
And suppose I have a backend service /getInfo?id= which returns a JSON object {foo: "bar"}.
Question:
1) What should I place in the API.getSomeEntity method?
2) How to make it asynchronous?
Basically, Backbone considers that if a model has a non-null id attribute, it exists on the remote API. And if you call fetch on that model instance, it will contact the API requesting the data. So you'd do something like this:
getSomeEntity: function(someEntityId) {
var myModel = new Entities.SomeEntity({id: someEntityId});
myModel.fetch();
return myModel;
}
Since you're using a non-standard API, you'll need to define your API endpoint also:
Entities.SomeEntity = Backbone.Model.extend({
url: function(){
return "/getInfo?id=" + this.get('id');
}
});
As to your last question: Backbone fetches the data asynchronously by default/design.

How to select distinct row in CouchDB?

I have the view:
function (doc) {
var obj;
obj = {
one:doc.document.someParameter1,
two:doc.document.someParameter2
};
emit(doc.document.id, obj);}
On request it returns several something like
{"total_rows":511,"offset":381,"rows":[
{"id":"CDOC_2.16.840.1.113883.3.59.3:0947___QCPR___80717","key":"7012979","value":{"one":"one","two":"two"}},
{"id":"CDOC_2.16.840.1.113883.3.59.3:0947___QCPR___80921","key":"7012979","value":{"one":"one","two":"two"}}
]}
Is there a way instead of several results get just one?
Of course, I could do filtering on the application side, but this could be very expensive since I have to transfer all unnecessary results.

Resources