-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi,
I have been playing around with the VersionOne JS SDK for node and have a few questions. I based my code on the sample.js file provided with the SDK.
What I'm trying to achieve is a query for Backlog Items where Status.Name is 'Prepared' and Scope.Name is 'My Project'
So I tried this:
v1.query({
from: "Story",
where: {
"Status.Name": "Prepared",
"Scope.Name": "My Project"
} // etc.
But that doesn't return any results, if I take out the "Status.Name" or "Scope.Name" property then I get results, I can filter out results based on the property values after they have been returned but it seems it doesn't work when I pass the two values in the 'where' clause. Am I doing something wrong here or is this expected behavior?
Also, I think there may be a defect in the v1meta.js file (or more correctly in the v1meta.coffee file). My 'success' function is being passed the same result object for every invocation. I believe it's down to the following loop in the V1Meta.prototype.query method:
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
assetxml = _ref[_i];
oidtoken = assetxml.get('id');
_ref1 = oidtoken.split(':'), found_type = _ref1[0], found_id = _ref1[1];
_results.push(_this.get_asset_class(found_type, function(err, Cls) {
var asset;
if (err != null) {
return options.error(err);
}
asset = _this.build_asset(Cls, assetxml);
return options.success(asset);
}));
}
The assetxml value is being overwritten everytime the loop iterates, but before the get_asset_class callback is called. Closing over the assetxml variable within the loop resolves it though
(function(thisAsset) {
_results.push(_this.get_asset_class(found_type, function(err, Cls) {
var asset;
if (err != null) {
return options.error(err);
}
asset = _this.build_asset(Cls, thisAsset);
return options.success(asset);
}));
})(assetxml);
I'm not really familiar enough with coffee script to make any useful contributions however.
I think it would also be useful to pass all the results to the success method rather than each result individually. Or perhaps if all results are passed to a done method instead.
Thanks!
Peter