Sourav301
Sourav301

Reputation: 1259

Query in 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.

Upvotes: 6

Views: 763

Answers (1)

Peter Aron Zentai
Peter Aron Zentai

Reputation: 11750

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.

Upvotes: 2

Related Questions