how to access database in javascript code example
Example 1: javascript read database
const config = {
"table" : "customers",
"limit" : "50",
"offset" : "0"
};
_POST_REQUEST("link-to-server/database.php", 'config=' + JSON.stringify(config), (response) => {
var data = JSON.parse(response);
});
Example 2: local database with javascript
var db = new PouchDB('dbname');
db.put({
_id: '[email protected]',
name: 'David',
age: 69
});
db.changes().on('change', function() {
console.log('Ch-Ch-Changes');
});
db.replicate.to('http://example.com/mydb');