Request in JayData

I want to query a simple sqlite database and get all the values ​​and print them in a <div> . The database table contains only user names and the corresponding "contact numbers" in the form of columns. Explain the logic of this.

+6
source share
1 answer

Connecting to existing sqlite databases is not officially supported by the current version; JayData needs to build database schemas to work. You can try to create a JavaScript schema that simply maps to an existing sqlite schema and see if JayData allows it to work, but this is a really complicated script.

If you let JayData manage the table for you, then

Create SQL table:

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

Click some data:

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

Extract data and put in div

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

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

+2
source

Source: https://habr.com/ru/post/948485/


All Articles