JS models. Database agnostic.
import * as data from 'maeva';
import mongodb from 'maeva-mongodb';
// Define a model
const players = data.model('players', {
name: String,
score: Number,
isCaptain: Boolean
});
// Use a data connector to connect to a database server
const connector = mongodb('mongodb://localhost');
const connection = data.connect(connector);
// Now you can fire requests to the database server
await data.insertOne(players, {
name: 'Joe',
score: 100,
isCaptain: true
});
// Find first 100 players sorted by score
await data.findMany(players, {
isCaptain: true,
name: /jo/,
score: data.above(0)
}, {sort: 'score', range: 100});
maeva
has been developed with the dichotomy client/server in mind. That's why we provide connectors for the two most basic ways a client app would fire queries: HTTP(s) and Web Sockets.
In your server app:
import * as data from 'maeva';
import postgres from 'maeva-postgresql';
import http from 'maeva-http';
const db = data.connect(postgres('pql://mypostgresserver.com'));
data.connect(http.server('http://myserver.com', {connector: db}));
In your client app:
import * as data from 'maeva';
import http from 'maeva-http';
const usersModel = data.model('users', {email: String});
data.connect(http('http://myserver.com'));
const users = await data.findMany(usersModel);
In your server app:
import * as data from 'maeva';
import postgres from 'maeva-postgresql';
import sockets from 'maeva-sockets';
const db = data.connect(postgres('pql://mypostgresserver.com'));
data.connect(sockets.server('ws://myserver.com', {connector: db}));
In your client app:
import * as data from 'maeva';
import sockets from 'maeva-sockets';
const usersModel = data.model('users', {email: String});
data.connect(sockets('ws://myserver.com'));
const users = await data.findMany(usersModel);
- maeva-firebase FireBase connector
- maeva-mongodb MongoDB connector
- maeva-mysql MySQL connector
- maeva-postgresql PostGreSQL connector
- maeva-json A json database that lives in memory - with an option to persist data in storage
- maeva-http A built-in HTTP API you can plug to any maeva connector
- maeva-sockets A built-in Web Socket API you can plug to any maeva connector