persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
I had trouble adding entities with one-to-many relationships. The statement always failed with the following error message:
Error: Property 'container' of 'Item' with id: [object Object] not fetched, either prefetch it or fetch it manually.
[Break On This Error]
exports.config = persistence.store.memory.config;
using the following program:
var Container = persistence.define( 'Container', { id: 'INT', size: 'INT' } )
var Item = persistence.define( 'Item', { name : "TEXT" } )
Container.hasMany( 'items', Item, 'container' )
persistence.store.memory.config( persistence )
persistence.schemaSync()
var container = new Container( { size : 10 } )
var item = new Item ( { name : 'foo'} )
container.items.add( item )
persistence.add( container )
persistence.flush()
Container.all().list( function( ctns )
{
console.log( ctns )
})
Then I found that I was actually overwriting a property that persistence is making use of. As 'id' is a common property in relational models, I think persistence should throw a exception when trying to add a property with that name.
I had trouble adding entities with one-to-many relationships. The statement always failed with the following error message:
using the following program:
Then I found that I was actually overwriting a property that persistence is making use of. As 'id' is a common property in relational models, I think persistence should throw a exception when trying to add a property with that name.