423 lines
9.6 KiB
HTML
Executable File
423 lines
9.6 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>DocStrap Source: documents/model.js</title>
|
|
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
|
|
|
<link type="text/css" rel="stylesheet" href="styles/site.amelia.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container-fluid">
|
|
<div class="navbar navbar-fixed-top navbar-inverse">
|
|
<div class="navbar-inner">
|
|
<a class="brand" href="index.html">DocStrap</a>
|
|
<ul class="nav">
|
|
|
|
<li class="dropdown">
|
|
<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b
|
|
class="caret"></b></a>
|
|
|
|
<ul class="dropdown-menu ">
|
|
|
|
<li>
|
|
<a href="module-base.html">base</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="chains_.html">base/chains</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="binder.html">documents/binder</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="model_.html">documents/model</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="probe.html">documents/probe</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="schema_.html">documents/schema</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="collector.html">ink/collector</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="bussable_.html">mixins/bussable</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="signalable_.html">mixins/signalable</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="format.html">strings/format</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="logger.html">utils/logger</a>
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
</li>
|
|
|
|
<li class="dropdown">
|
|
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
|
class="caret"></b></a>
|
|
|
|
<ul class="dropdown-menu ">
|
|
|
|
<li>
|
|
<a href="base.html">base</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="chains.html">base/chains</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="model.html">documents/model</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="probe.queryOperators.html">documents/probe.queryOperators</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="probe.updateOperators.html">documents/probe.updateOperators</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="collector-ACollector.html">ink/collector~ACollector</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="collector-CollectorBase_.html">ink/collector~CollectorBase</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="collector-OCollector.html">ink/collector~OCollector</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="signalable-Signal.html">mixins/signalable~Signal</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="logger.Logger.html">utils/logger.Logger</a>
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
</li>
|
|
|
|
<li class="dropdown">
|
|
<a href="mixins.list.html" class="dropdown-toggle" data-toggle="dropdown">Mixins<b
|
|
class="caret"></b></a>
|
|
|
|
<ul class="dropdown-menu ">
|
|
|
|
<li>
|
|
<a href="schema.html">documents/schema</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="bussable.html">mixins/bussable</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="signalable.html">mixins/signalable</a>
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
</li>
|
|
|
|
<li class="dropdown">
|
|
<a href="tutorials.list.html" class="dropdown-toggle" data-toggle="dropdown">Tutorials<b
|
|
class="caret"></b></a>
|
|
|
|
<ul class="dropdown-menu ">
|
|
|
|
<li>
|
|
<a href="tutorial-Teeth.html">Brush Teeth</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="tutorial-Car.html">Drive Car</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="tutorial-Test.html">Fence Test</a>
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
</li>
|
|
|
|
<li class="dropdown">
|
|
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
|
class="caret"></b></a>
|
|
|
|
<ul class="dropdown-menu ">
|
|
|
|
<li>
|
|
<a href="global.html#utils/logger">utils/logger</a>
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row-fluid">
|
|
|
|
|
|
<div class="span12">
|
|
|
|
<div id="main">
|
|
|
|
|
|
|
|
<h1 class="page-title">Source: documents/model.js</h1>
|
|
|
|
<section>
|
|
<article>
|
|
<pre
|
|
class="sunlight-highlight-javascript linenums">"use strict";
|
|
/**
|
|
* @fileOverview A model is the first level if usable data-bearing entity in the system. It does NOT include any verbs for saving or anything like
|
|
* that, it is a pure, in memory data container
|
|
* @module documents/model
|
|
* @require base
|
|
* @require documents/probe
|
|
* @require lodash
|
|
*/
|
|
|
|
var Base = require( "../base" );
|
|
var probe = require( "./probe" );
|
|
var sys = require( "lodash" );
|
|
/**
|
|
* A model is the first level if usable data-bearing entity in the system. It does NOT include any verbs for saving or anything like
|
|
* that, it is a pure, in memory data container
|
|
* @exports documents/model
|
|
* @constructor
|
|
* @borrows module:documents/probe.get as get
|
|
* @borrows module:documents/probe.set as set
|
|
* @borrows module:documents/probe.any as any
|
|
* @borrows module:documents/probe.all as all
|
|
* @borrows module:documents/probe.remove as remove
|
|
* @borrows module:documents/probe.seekKey as seekKey
|
|
* @borrows module:documents/probe.seek as seek
|
|
* @borrows module:documents/probe.findOne as findOne
|
|
* @borrows module:documents/probe.findOneKey as findOneKey
|
|
* @borrows module:documents/probe.findKeys as findKeys
|
|
* @borrows module:documents/probe.find as find
|
|
* @borrows module:documents/probe.update as update
|
|
* @borrows module:documents/probe.some as some
|
|
* @borrows module:documents/probe.every as every
|
|
*/
|
|
var Model = Base.compose( [Base], /** @lends documents/model# */{
|
|
constructor : function () {
|
|
var that = this;
|
|
probe.mixin( this );
|
|
|
|
var idField = "_id";
|
|
/**
|
|
* The name of the field that uniquely identifies a record. When provided, some operations will take advantage of it
|
|
*
|
|
* @name _idField
|
|
* @memberOf documents/model#
|
|
* @type {string}
|
|
* @private
|
|
*/
|
|
Object.defineProperty( this, "_idField", {
|
|
get : function () {
|
|
return idField;
|
|
},
|
|
set : function ( val ) {
|
|
idField = val;
|
|
},
|
|
configurable : false,
|
|
enumerable : true,
|
|
writable : true
|
|
} );
|
|
|
|
/**
|
|
* The value of the primary key if {@link documents/model#_idField} is filled in. It will be null if none found
|
|
*
|
|
* @name _pkey
|
|
* @memberOf documents/model#
|
|
* @type {*}
|
|
* @private
|
|
*/
|
|
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
|
|
} );
|
|
|
|
/**
|
|
* If {@link documents/model#_idField} is filled in and it's value is empty this will be true.
|
|
* @type {boolean}
|
|
* @name isNew
|
|
* @memberOf documents/model#
|
|
*/
|
|
Object.defineProperty( this, "isNew", {
|
|
get : function () {
|
|
return !sys.isEmpty( that._idField ) && !sys.isEmpty( that[that._idField] )
|
|
},
|
|
configurable : false,
|
|
enumerable : true,
|
|
writable : false
|
|
} );
|
|
|
|
/**
|
|
* Returns true if this instance is empty
|
|
* @type {boolean}
|
|
* @name isEmpty
|
|
* @memberOf documents/model#
|
|
*/
|
|
Object.defineProperty( this, "isEmpty", {
|
|
get : function () {
|
|
return sys.isEmpty( that );
|
|
},
|
|
configurable : false,
|
|
enumerable : true,
|
|
writable : false
|
|
} );
|
|
}
|
|
} );
|
|
module.exports = Model;
|
|
</pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="clearfix"></div>
|
|
<footer>
|
|
|
|
|
|
<span class="copyright">
|
|
DocStrap Copyright © 2012-2013 The contributors to the JSDoc3 and DocStrap projects.
|
|
</span>
|
|
<br />
|
|
|
|
<span class="jsdoc-message">
|
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a>
|
|
on Mon Jul 7th 2014 using the <a
|
|
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
|
</span>
|
|
</footer>
|
|
</div>
|
|
|
|
|
|
<br clear="both">
|
|
</div>
|
|
|
|
</div>
|
|
<!--<script src="scripts/sunlight.js"></script>-->
|
|
<script src="scripts/docstrap.lib.js"></script>
|
|
<script src="scripts/bootstrap-dropdown.js"></script>
|
|
<script src="scripts/toc.js"></script>
|
|
|
|
<script>
|
|
$( function () {
|
|
$( "[id*='$']" ).each( function () {
|
|
var $this = $( this );
|
|
|
|
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
|
|
} );
|
|
|
|
$( "#toc" ).toc( {
|
|
anchorName : function ( i, heading, prefix ) {
|
|
return $( heading ).attr( "id" ) || ( prefix + i );
|
|
},
|
|
selectors : "h1,h2,h3,h4",
|
|
showAndHide : false,
|
|
scrollTo : "100px"
|
|
} );
|
|
|
|
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
|
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
|
$( '.dropdown-toggle' ).dropdown();
|
|
// $( ".tutorial-section pre, .readme-section pre" ).addClass( "sunlight-highlight-javascript" ).addClass( "linenums" );
|
|
|
|
$( ".tutorial-section pre, .readme-section pre" ).each( function () {
|
|
var $this = $( this );
|
|
|
|
var example = $this.find( "code" );
|
|
exampleText = example.html();
|
|
var lang = /{@lang (.*?)}/.exec( exampleText );
|
|
if ( lang && lang[1] ) {
|
|
exampleText = exampleText.replace( lang[0], "" );
|
|
example.html( exampleText );
|
|
lang = lang[1];
|
|
} else {
|
|
lang = "javascript";
|
|
}
|
|
|
|
if ( lang ) {
|
|
|
|
$this
|
|
.addClass( "sunlight-highlight-" + lang )
|
|
.addClass( "linenums" )
|
|
.html( example.html() );
|
|
|
|
}
|
|
} );
|
|
|
|
Sunlight.highlightAll( {
|
|
lineNumbers : true,
|
|
showMenu : true,
|
|
enableDoclinks : true
|
|
} );
|
|
} );
|
|
</script>
|
|
|
|
|
|
|
|
<!--Navigation and Symbol Display-->
|
|
|
|
|
|
|
|
<!--Google Analytics-->
|
|
|
|
|
|
</body>
|
|
</html>
|