Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query in JayData

Tags:

jaydata

I want to query a simple sqLite database and get all the values and print them in a <div> . The Database Table just has person "names" and corresponding "Contact numbers" as columns. Please Explain the logic to do so.

like image 349
Sourav301 Avatar asked Jul 01 '13 16:07

Sourav301


1 Answers

Connecting to existing sqLite databases is not officially supported by the current version, JayData needs to build its database schemas in order to operate. You might try to create a JavaScript schema that just maps to the existing sqLite schema and see if JayData let's you work with it but it is really a tough scenario.

If you let JayData manage the table for you then

Create SQL table:

var Person = $data.define("Person", {
   name: String,
   contact: String
}); 

Push some data:

Person.addMany([{name: 'john'}, {name:'jane', contact: '555-1234'}]);

Retrive data and put to div

Person.readAll().then(function(persons) {
    persons.forEach(function(person) {
       $('#list').append(person.name);
    });
});

If you are interested in this approach you can read more on the JayData ItemStore API.

like image 82
Peter Aron Zentai Avatar answered Oct 04 '22 01:10

Peter Aron Zentai