I created a DB and added these
var db = new Dexie("oneGBUApp");
db.version(1).stores({
eventsz: 'typeo,nameo,organizer, locationo,startdate, enddate, participents',
// ...add more stores (tables) here...
});
db.events.add({typeo: 'Training',nameo: 'Leadership training',organizer: 'Prashant Dangash', locationo: 'India', startdate: 'SD', enddate:'ed', participents:'toCCbcc'});
db.events.add({typeo: 'sports2',nameo: 'volly ball',organizer: 'oneGBU2', locationo: 'Campus2', startdate: 'SD', enddate:'ed', participents:'toCCbcc'});
db.events.add({typeo: 'sports3',nameo: 'base ball',organizer: 'oneGBU3', locationo: 'Campus3', startdate: 'SD', enddate:'ed', participents:'toCCbcc'});
db.events.add({typeo: 'sports4',nameo: 'basket ball2',organizer: 'oneGBU4', locationo: 'Campus4', startdate: 'SD', enddate:'ed', participents:'toCCbcc'});
db.events.where('typeo').startsWith('sports').each(function(events){
console.log(events.name);
});
This works fine.,
I need only the json result and not writableTable ... In other words ., how can i get the data as plain json ... something like below
eventsz :[
{typeo: 'Training',nameo: 'Leadership training',organizer: 'Prashant Dangash', locationo: 'ATP Tower C Cafetria', startdate: '12:30', enddate:'13:30', participents:'toCCbcc'},
{typeo: 'Training2',nameo: 'OneGBU Collobration',organizer: 'Prashant Dangash2', locationo: 'ATP 5th floor 5D003', startdate: '14:30', enddate:'15:30', participents:'toCCbcc2'}]
Any help is much appericiated., I am trying to integrate with knockout... for ui bindings...
Regards.,Muthuveerappan
You can use toArray() or first() or any other of the Collection methods in API Reference.
var queryPromise = db.events.where('typeo').startsWith('sports').toArray();
// Now consume this promise using the standard `then` and `catch` methods
queryPromise.then(function (events) {
// Here, eventz is an array of database objects.
// Do you really need their JSON version? If so,
return JSON.stringify(events);
}).then(function (json) {
console.log(json);
}).catch(function (error) {
console.error (error.stack);
});
Closing
Thanks., it worked ...