0.4.2 • Published 9 years ago
schema-mapper-api v0.4.2
schema-mapper-api
A module to retrieve, modify and save schemas via node or over HTTP.
Installation
npm install --save schema-mapper-api
Usage
var Api = require('schema-mapper-api');
// Setup connection to the schema-mapper-store
var store = new Api('http://localhost:9000');
// Retrieve a ProjectCollection
store.getProjectCollection()
.then(function (projectCollection) {
var project = {
name: 'demo', // Project name (similar to a database name)
version: 1, // Project version (versions is where schema-mapper shines)
schemas: {
// The keys in this oject are the unique id's for the schema
'0': {
name: 'users', // Schema name (similar to a database table)
primary: '0', // The schema id of the primary key
columns: {
// The keys in this object are the unique id's for the columns
'0': {
name: 'id', // Column name (similar to database column name)
type: 'integer' // Column type (see spec which types are supported)
},
'1': {
name: 'email',
type: 'string'
}
}
}
}
};
projectCollection.putProject('0', project);
// Save the ProjectCollection
// the ProjectCollection will be diffed with it's original version, only the changes will be sent to the store (via the Api), returns promise
return projectCollection.save();
})
.then(function () {
// The changes from the putProject command above are a project.create change and a project.tag change,
// after these changes have been applied the storage engines are ready to accept data
var item = {
id: 1,
email: 'hello@world.com'
};
return store.putItem(projectId, schemaId, item);
});
API docs
For more methods on the store, see the docs at Api Docs
For more methods on the project collection, see the docs at ProjectCollection Docs
Licence
MIT
0.4.2
9 years ago
0.4.1
9 years ago
0.4.0
9 years ago
0.3.2
10 years ago
0.3.1
10 years ago
0.3.0
10 years ago
0.2.2
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.6
10 years ago
0.1.5
10 years ago
0.1.4
10 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago