Registered as js-data
in NPM and Bower.
Also available from CDN.JS and JSDelivr.
npm i --save js-data@beta
bower i --save js-data@3.0.0-beta.1
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-data/3.0.0-beta.1/js-data.min.js"></script>
<script src="https://cdn.jsdelivr.net/js-data/3.0.0-beta.1/js-data.min.js"></script>
<script src="/path/to/js-data.min.js"></script>
<script>
console.log(JSData.version.full); // "3.0.0-beta.1"
</script>
var JSData = require('js-data');
import * as JSData from 'js-data';
define('myApp', ['js-data'], function (JSData) { ... })
Members
-
<static> Collection
-
JSData's Collection class.
DetailsType Since Source Tutorials See Constructor 3.0.0 index.js, line 65 Exampleimport {Collection} from 'js-data' const collection = new Collection()
-
<static> Component
-
JSData's Component class. Most components in JSData extend this class.
DetailsType Since Source See Constructor 3.0.0 index.js, line 80 Exampleimport {Component} from 'js-data' // Make a custom component. const MyComponent = Component.extend({ myMethod (someArg) { ... } })
-
<static> Container
-
JSData's Container class. Defines and manages Mappers. Used in Node.js and in the browser, though in the browser you may want to use DataStore instead.
DetailsType Since Source Tutorials See Constructor 3.0.0 index.js, line 98 Exampleimport {Container} from 'js-data' const store = new Container()
-
<static> DataStore
-
JSData's DataStore class. Primarily for use in the browser. In Node.js you probably want to use Container instead.
DetailsType Since Source Tutorials See Constructor 3.0.0 index.js, line 115 Exampleimport {DataStore} from 'js-data' const store = new DataStore()
-
<static> Index
-
JSData's Index class, based on mindex.
DetailsType Since Source See Constructor 3.0.0 index.js, line 131 - Index
-
<static> LinkedCollection
-
JSData's LinkedCollection class. Used by the DataStore component. If you need to create a collection manually, you should probably use the Collection class.
DetailsType Since Source See Constructor 3.0.0 index.js, line 141 -
<static> Mapper
-
JSData's Mapper class. The core of the ORM.
DetailsType Since Source Tutorials See Constructor 3.0.0 index.js, line 154 Examplesimport {Container} from 'js-data' const store = new Container() store.defineMapper('user')
import {Mapper} from 'js-data' const UserMapper = new Mapper({ name: 'user' })
-
<static> Query
-
JSData's Query class. Used by the Collection component.
DetailsType Since Source See Constructor 3.0.0 index.js, line 176 -
<static> Record
-
JSData's Record class.
DetailsType Since Source Tutorials See Constructor 3.0.0 index.js, line 186 Exampleimport {Container} from 'js-data' const store = new Container() store.defineMapper('user') const user = store.createRecord('user')
-
<static> Schema
-
JSData's Schema class. Implements http://json-schema.org/draft-04.
DetailsType Since Source Tutorials See Constructor 3.0.0 index.js, line 203 Exampleimport {Container, Schema} from 'js-data' const userSchema = new Schema({ properties: { id: { type: 'string' }, name: { type: 'string' } } }) const store = new Container() store.defineMapper('user', { schema: userSchema })
-
<static> utils
-
JSData's utility methods.
Properties:
Name Type Description Promise
Function See utils.Promise.
Exampleimport {utils} from 'js-data' console.log(utils.isString('foo')) // true
-
<static> version
-
Describes the version of this
JSData
object.Properties:
Name Type Description full
String The full semver value.
major
Number The major version number.
minor
Number The minor version number.
patch
Number The patch version number.
alpha
String | Boolean The alpha version value, otherwise
false
if the current version is not alpha.beta
String | Boolean The beta version value, otherwise
false
if the current version is not beta.Exampleconsole.log(JSData.version.full) // "3.0.0-beta.1"
Methods
-
<static> belongsTo(related, opts)
-
TODO
Method parameters:Name Type Description related
Mapper The relation the target belongs to.
opts
Object Configuration options.
Properties
Name Type Description foreignKey
String The field that holds the primary key of the related record.
localField
String The field that holds a reference to the related record object.
Return value:Type Description Function Invocation function, which accepts the target as the only parameter.
DetailsSource decorators.js, line 114 -
<static> hasMany(related, opts)
-
TODO
Method parameters:Name Type Description related
Mapper The relation of which the target has many.
opts
Object Configuration options.
Properties
Name Type Argument Description foreignKey
String <optional>
The field that holds the primary key of the related record.
localField
String The field that holds a reference to the related record object.
Return value:Type Description Function Invocation function, which accepts the target as the only parameter.
DetailsSource decorators.js, line 136 -
<static> hasOne(related, opts)
-
TODO
Method parameters:Name Type Description related
Mapper The relation of which the target has one.
opts
Object Configuration options.
Properties
Name Type Argument Description foreignKey
String <optional>
The field that holds the primary key of the related record.
localField
String The field that holds a reference to the related record object.
Return value:Type Description Function Invocation function, which accepts the target as the only parameter.
DetailsSource decorators.js, line 158