Simple Node.js ODM inspired by Mongoose and Ottoman but database agnostic
Frontier is a simple, somewhat opinionated, Mongoose/Ottoman-inspired ODM.
const Frontier = require('frontier');
const Adapter = require('frontier/adapters/InMemoryAdapter');
class Address extends Frontier.Model {
static schema() {
return {
number: 'number',
street: 'string',
suburb: 'string',
city: 'string',
country: 'string',
};
}
}
class User extends Frontier.Model {
static schema() {
return {
email: 'string',
name: 'string',
address: { type: Address },
};
}
}
const frontier = new Frontier({ models: [Address, User] });
const store = new Frontier.Datastore({ Adapter });
const repo = frontier.createRepository(store);
(async () => {
const user = new repo.models.User({
name: 'James Bond',
email: '007@mi6.gov.uk',
address: new repo.models.Address({
number: 85,
street: 'Albert Embankment',
suburb: 'Vauxhall',
city: 'London',
country: 'UK',
}),
});
await user.save();
const dbUser = await repo.models.User.find({ address: { city: 'London' } });
console.log({ user, dbUser });
})();
- ES6 Classes for Models
- ES6 Async/Await support
- Generate GraphQL types and default resolvers
- Pass through cache for repositories (Dataloader)
- Model Metadata (e.g. meta.demoId)
- Chainable API
- Model Version Migrations
- Fake Generator for Models
Model.Fake({ args })
- Adapter Performance Testing
- Model Network Diagram (GraphQLVoyager)
- Data Navigator Network Diagram
- On demand graph loading with proxies
- Improved validation onLoad and onSave using https://github.com/chriso/validator.js
- TypeScript support
- typescript class properties validator
- Realtime data listeners
- could use DCP for couchbase similar to https://github.com/couchbaselabs/python-dcp-client
- https://stackoverflow.com/questions/26262194/monitoring-a-couchbase-bucket-with-libevent?rq=1
API interface inspired by Ottoman. Icon made by Those Icons from www.flaticon.com is licensed by CC 3.0 BY