So in my project am using persistence.js to sync databases on mobile devices with dbs on a node.js server and my server is required to host multiple DBs.
The mobile app I am developing might call the server for synching with a particular DB. So at any point of time AppA running on a phone could call server to synch with DB1 and at the same time AppB could make a call (from another phone) to sync with DB2.
My question here is will persistence.js perform well in such a scenario, as we know Persistence.js is essentially a singleton. How will it handle 2 concurrent requests to different DBs??? And should I alter the code for such a scenario... Hope my question is clear...
What's going on in your project? I have the exactly same requirement to sync DBs between devices. I tested persisntence serer sync, and also found some issues. Are you going to contribute to github or create a new branch?
On Wednesday, April 11, 2012 7:12:24 PM UTC+8, Sudhakar Fomra wrote:
> Hey Zef,
> So in my project am using persistence.js to sync databases on mobile > devices with dbs on a node.js server and my server is required to host > multiple DBs.
> The mobile app I am developing might call the server for synching with a > particular DB. So at any point of time AppA running on a phone could call > server to synch with DB1 and at the same time AppB could make a call (from > another phone) to sync with DB2.
> My question here is will persistence.js perform well in such a scenario, > as we know Persistence.js is essentially a singleton. How will it handle 2 > concurrent requests to different DBs??? And should I alter the code for > such a scenario... Hope my question is clear...
If you don't mind using jQuery, what about something like this?
<code>
var PersistenceJS = function(dbname, description, size)
{
jQuery.extend(true, this, persistence);
this.store.websql.config(this, dbname, description, size);
};
PersistenceJS.prototype = new Object();
PersistenceJS.prototype.constructor = PersistenceJS;
</code>
<code>
$(document).ready( function()
{
var dbA = new PersistenceJS('dba', 'DBA', 1024 * 1024);
dbA.debug = true;
var EntityA = dbA.define('EntityA', {});
EntityA.enableSync();
var dbB = new PersistenceJS('dbb', 'DBB', 1024 * 1024);
dbB.debug = true;
var EntityB = dbB.define('EntityB', {});
EntityB.enableSync();
> What's going on in your project? I have the exactly same requirement to
> sync DBs between devices. I tested persisntence serer sync, and also found
> some issues. Are you going to contribute to github or create a new branch?
> Thanks,
> Mason
> On Wednesday, April 11, 2012 7:12:24 PM UTC+8, Sudhakar Fomra wrote:
>> Hey Zef,
>> So in my project am using persistence.js to sync databases on mobile
>> devices with dbs on a node.js server and my server is required to host
>> multiple DBs.
>> The mobile app I am developing might call the server for synching with a
>> particular DB. So at any point of time AppA running on a phone could call
>> server to synch with DB1 and at the same time AppB could make a call (from
>> another phone) to sync with DB2.
>> My question here is will persistence.js perform well in such a scenario,
>> as we know Persistence.js is essentially a singleton. How will it handle 2
>> concurrent requests to different DBs??? And should I alter the code for
>> such a scenario... Hope my question is clear...
>> Cheers,
>> SF.
-- "When pride comes, then comes disgrace, but with humility comes wisdom."
—Proverbs 11:2
If you want to use different stores across DBs, you can pass it as a parameter.
<code>
var PersistenceJS = function(dbname, description, size, store)
{
store = store || 'websql';
if( store in this.store )
{
jQuery.extend(true, this, persistence);
this.store[store].config(this, dbname, description, size);
}
else
{
console.error( "Unknown PersistenceJS store '" + store "'." );
}
};
</code>
Regards,
Mark M. Young
-- "When pride comes, then comes disgrace, but with humility comes wisdom."
—Proverbs 11:2
I posted prematurely--I found a logic error and a syntax error.
var PersistenceJS = function(dbname, description, size, store)
{
store = store || 'websql';
jQuery.extend(true, this, persistence);
if( store in this.store )
{
this.store[store].config(this, dbname, description, size);
}
else
{
console.error( "Unknown PersistenceJS store '" + store + "'." );
}
};
Regards,
Mark M. Young
On 7/9/12, Mark M. Young <milburn.yo...@gmail.com> wrote:
> If you want to use different stores across DBs, you can pass it as a
> parameter.
> <code>
> var PersistenceJS = function(dbname, description, size, store)
> {
> store = store || 'websql';
> if( store in this.store )
> {
> jQuery.extend(true, this, persistence);
> this.store[store].config(this, dbname, description, size);
> }
> else
> {
> console.error( "Unknown PersistenceJS store '" + store "'." );
> }
> };
> </code>
> Regards,
> Mark M. Young
> --
> "When pride comes, then comes disgrace, but with humility comes wisdom."
> —Proverbs 11:2
-- "When pride comes, then comes disgrace, but with humility comes wisdom."
—Proverbs 11:2