TaffyDB alphabetical order

233 views Asked by At

I am using TaffyDB (JavaScript library) and was able to successfully store my records into a database but I am having some trouble outputting the results in the correct format.

results().select("Name","Topic","Difficulty"))

This code would output my columns in alphabetical order. It would output as (Difficulty, Name, Topic) but I need to output it as ("Name, Topic, Difficulty"). I've tried looking at the documentation but I wasn't able to make a working solution.

1

There are 1 answers

0
Aniruddha Gohad On BEST ANSWER
results().select("Name","Topic","Difficulty"))

should be

results().select("Name","Topic","Difficulty")

notice the extra ")" at the end.

I have tried using your code and it DOESNT return in an alphabetical order.

go to http://www.javascriptoo.com/taffydb and change the code inside the script to :

    var people= TAFFY();
    people.insert({"fname":"Bruce","lname":"Wayne", "id":1});
    people.insert({"fname":"Peter","lname":"Parker", "id":2});
    people.insert({"fname":"Clark","lname":"Kent", "id":3});
    write("people().select('fname','lname', 'id')");
     function write(func){
        var ret = eval(func);
        var output = (typeof ret === 'object') ? JSON.stringify(ret) : ret;
        document.getElementById('results').innerHTML+= '<li>' + func + '<br />=><b>'+output+'</b>';
    }