jaydata/jaydata — pull request #178 by genne5 (2014-05-15 09:40:47+00:00)
Title: Support for:  Bulk-Insert & MSOpenTech's cordova WebSQL plugin

Part 1:
MSOpenTech has just released a plugin which supports SQLite in Windows 8
Store Apps.
https://github.com/MSOpenTech/cordova-plugin-websql
This plugin uses JSON.net for serializing .Net Object to JSON, but they
have not set the NullValueHandling to NullValueHandling.Ignore, so the
result always contains the properties insertId and rowsAffected. A
compare to "undefined" will not work here.
With your version, your will never get result-objects reflected to your
businesslogic.
At times I will also contribute a change-request to the cordova-plugin.

Part 2:
scenario with 10000 entities
old method (addMany + saveChanges) --> 3700ms
new method (bulkInsert(entiyet, fields, entityArray, callBack)) -->
500ms

dev-pc: iCore7, 8GB RAM, SSD

here is my test-code:
var ProvedModel = (function () {
return {
createContext: function () {
$data.Entity.extend("$JOMOsoft.Entities.BER", {
BER_ID: { type: "int", key: true, computed: true },
BER_NAME: { type: "string" },
BER_KURZ: { type: "string" }
});
$data.EntityContext.extend("$JOMOsoft.Entities.DbContext", {
BER: {
type: $data.EntitySet,
elementType: $JOMOsoft.Entities.BER
}
});

var dbName = "JOMOsoftDB";
var providerName = "local";

$JOMOsoft.context = new $JOMOsoft.Entities.DbContext(
{
name: providerName,
databaseName: dbName,
dbCreation: $data.storageProviders.DbCreationType.DropAllExistingTables
});
}
}
}());

var count = 10000;

ProvedModel.createContext();
$JOMOsoft.context.onReady(function (ctx) {

var list = new Array();
for (var i = 1; i <= count; i++) {
list.push({ BER_ID: i, BER_NAME: 'Name', BER_KURZ: 'Kurz' });
}
var start = new Date().getTime();
var callBack = {
success: function (data) {
var end = new Date().getTime();
var time = end - start;
console.log('Jaydata Execution time: ' + time);
},
error: function (data) {
console.log(data);
}
};

start = new Date().getTime();

// new Version --> 500ms
ctx.bulkInsert(ctx.BER, undefined, list, callBack);

// old-Version --> 3700ms
//ctx.BER.addMany(list);
//ctx.saveChanges(callBack);
});