6

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.

Sourav301
  • 1,259
  • 1
  • 14
  • 24

1 Answers1

2

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.

Peter Aron Zentai
  • 11,482
  • 5
  • 41
  • 71