contributions/mobl/www/js/persistence.store.sql.js
/**
   * Converts a database row into an entity object
   */
Converts a database row into an entity object
Converts a database row into an entity object
function rowToEntity(session, entityName, row, prefix) {
    prefix = prefix || '';
    if (session.trackedObjects[row[prefix + "id"]]) { 
      return session.trackedObjects[row[prefix + "id"]];
    }
    var tm = persistence.typeMapper;
    var rowMeta = persistence.getMeta(entityName);
    var ent = persistence.define(entityName); 
    if(!row[prefix+'id']) { 
      return null;
    }
    var o = new ent();
    o.id = tm.dbValToEntityVal(row[prefix + 'id'], tm.idType);
    o._new = false;
    for ( var p in row) {
      if (row.hasOwnProperty(p)) {
        if (p.substring(0, prefix.length) === prefix) {
          var prop = p.substring(prefix.length);
          if (prop != 'id') {
            o._data[prop] = tm.dbValToEntityVal(row[p], rowMeta.fields[prop] || tm.idType);
          }
        }
      }
    }
    return o;
  }
function rowToEntity ( session , entityName , row , prefix ) { prefix = prefix || '' ; if ( session . trackedObjects [ row [ prefix + "id" ] ] ) { return session . trackedObjects [ row [ prefix + "id" ] ] ; } var tm = persistence . typeMapper ; var rowMeta = persistence . getMeta ( entityName ) ; var ent = persistence . define ( entityName ) ; if ( ! row [ prefix + 'id' ] ) { return null ; } var o = new ent ( ) ; o . id = tm . dbValToEntityVal ( row [ prefix + 'id' ] , tm . idType ) ; o . _new = false ; for ( var p in row ) { if ( row . hasOwnProperty ( p ) ) { if ( p . substring ( 0 , prefix . length ) === prefix ) { var prop = p . substring ( prefix . length ) ; if ( prop != 'id' ) { o . _data [ prop ] = tm . dbValToEntityVal ( row [ p ] , rowMeta . fields [ prop ] || tm . idType ) ; } } } } return o ; }
Converts a database row into an entity object
Converts a database row into an entity object
// Cached version // Get entity // null value, no entity found