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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With