Package Exports
- data
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (data) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Data.js
Data.js is a data representation framework for Javascript. It's being developed in the context of Substance, an open publishing platform.
For documentation, usage, and examples, see the offical documentation: http://substance.io/michael/data-js
With Data.js you can:
- Model your domain data using a simple graph-based object model that can be serialized to JSON.
- Traverse your graph, including relationships using a simple API.
- Manipulate and query data on the client (browser) or on the server (Node.js) by using exactly the same API.
Features
Data.Graph
(A data abstraction for all kinds of linked data)Data.Collection
(A simplified interface for tabular data)
Getting Started
Define a schema
var schema = {
"/type/person": {
"type": "/type/type",
"name": "Person",
"properties": {
"name": {"name": "Name", "type": "string", "required": true},
"origin": {"name": "Origin", "type": "/type/location" }
}
},
"/type/location": {
"type": "/type/type",
"name": "Location",
"properties": {
"name": { "name": "Name", "unique": true, "type": "string", "required": true },
"citizens": {"name": "Citizens", "unique": false, "type": "/type/person"}
}
}
};
Create a new Data.Graph.
var graph = new Data.Graph(schema);
Add some objects.
graph.set({
_id: "/person/bart",
type: "/type/person",
name: "Bart Simpson"
});
graph.set({
_id: "/location/springfield",
name: "Springfield",
type: "/type/location",
citizens: ["/person/bart"]
});
Set properties (including relationships to other objects)
graph.get('/person/bart')
.set({origin: '/location/springfield'});
Access your data.
var citizens = graph.get('/location/springfield').get('citizens');
_.each(citizens, function(person) {
console.log(person.get('name'));
});