I have a bit of code that draws from a Taffy db, to create an object that I then iterate through. In previous versions, the order of the elements in the object were consistent in their order (although I realize this is not guaranteed in js), so I was accessing them through this[0]
, this[1]
, etc. In the new version (apparently due to a Taffy bug, https://github.com/typicaljoe/taffydb/issues/109), this behaviour is not reliable, so I would like to know if there is a more robust way to structure the information and retrieve it. A minimal example:
var stuffWeCite = TAFFY([{
"first": 1,
"second": 2,
"third": 3,
"fourth": 4
}]);
var filterVar = {"first":1};
var someVar = stuffWeCite()
.filter(filterVar)
.select("first", "second", "third", "fourth");
console.log('someVar: ' + someVar);
Previously, the result would appear 1, 2, 3, 4, but the behaviour has changed.
If I were entering the elements of the query into an object one-by-one, I would assign them properties ("first", "second", etc.) and then call those later, but the way they are selected seems to preclude this. Is there a way I can assign properties to the values when creating the object from a db query?