Aaron Bratcher
Aaron Bratcher

Reputation: 6451

TaffyDB: Select problems

I'm new to TaffyDB and haven't done a lot of javascript programming so I'm hoping that the problem I'm having is something simple. I'm trying to update a listbox with the options stored in the TaffyDB according to the selected client. When I do my select however, it is returning all the rows.

Below is the code I am using to update the listbox, along with the selectString used to do the query, and what's in the TaffyDB.

Anyone have any ideas why I am getting back all rows when I specify clientID = 1788?

I tried the select string with and without quotes around the column identifier.

// load existing user client projects if we have any
var lbProjects = document.getElementById('lbProjects');
lbProjects.options.length = 0;
var selectString = '{clientID:"' + clientID + '"}';
alert(selectString);
userProjects(selectString).each(
function (r) {
    var option = new Option();
    option.value = r.projectID;
    option.text = r.projectName;
    lbProjects.add(option, null);
});

What's in selectString: {clientID:"1788"}

What's in the DB: [{"clientID":"1788","projectID":"19"}, {"clientID":"1789","projectID":"24"}, {"clientID":"1790","projectID":"23"}]

Thanks for any help. Aaron L. Bratcher

Upvotes: 0

Views: 1327

Answers (1)

Aaron Bratcher
Aaron Bratcher

Reputation: 6451

The problem was trying to use the selectString variable.

The line

userProjects(selectString).each( 

now reads

userProjects({clientID: clientIDValue}).each(

I was supposed to be passing in an object array, not a string. {} in javascript creates an array of objects.

Upvotes: 1

Related Questions