123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- "use strict";
- var Base = require( "../base" );
- var probe = require( "./probe" );
- var sys = require( "lodash" );
- var Model = Base.compose( [Base], {
- constructor : function () {
- var that = this;
- probe.mixin( this );
- var idField = "_id";
-
- Object.defineProperty( this, "_idField", {
- get : function () {
- return idField;
- },
- set : function ( val ) {
- idField = val;
- },
- configurable : false,
- enumerable : true,
- writable : true
- } );
-
- Object.defineProperty( this, "_pkey", {
- get : function () {
- var val;
- if ( !sys.isEmpty( that._idField ) ) {
- val = that[that._idField];
- }
- return val;
- },
- set : function ( val ) {
- if ( !sys.isEmpty( that._idField ) ) {
- that[that._idField] = val;
- }
- },
- configurable : false,
- enumerable : true,
- writable : true
- } );
-
- Object.defineProperty( this, "isNew", {
- get : function () {
- return !sys.isEmpty( that._idField ) && !sys.isEmpty( that[that._idField] )
- },
- configurable : false,
- enumerable : true,
- writable : false
- } );
-
- Object.defineProperty( this, "isEmpty", {
- get : function () {
- return sys.isEmpty( that );
- },
- configurable : false,
- enumerable : true,
- writable : false
- } );
- }
- } );
- module.exports = Model;
|