# maeva

> Agnostic database models in JavaScript

Latest version **4.4.17** (published 2018-03-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install maeva
pnpm add maeva
yarn add maeva
bun add maeva
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.4.17 |
| Published | 2018-03-08 |
| First published | 2016-09-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 467.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | francoisv |

## Links

- npm: https://www.npmjs.com/package/maeva
- npm.io page: https://npm.io/package/maeva

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.15.0
- [reactors-icons](https://npm.io/package/reactors-icons.md) ^3.0.13
- [docusaurus-init](https://npm.io/package/docusaurus-init.md) ^1.0.1

## Recent versions

- 4.4.17 (latest) — 2018-03-08
- 4.4.16 — 2018-03-08
- 4.4.15 — 2018-03-08
- 4.4.14 — 2018-03-08
- 4.4.13 — 2018-03-08
- 4.4.12 — 2018-03-07
- 4.4.11 — 2018-03-07
- 4.4.10 — 2018-03-01
- 4.4.9 — 2018-03-01
- 4.4.8 — 2018-02-28
- 4.4.7 — 2018-02-28
- 4.4.6 — 2018-02-28
- 4.4.5 — 2018-02-26
- 4.4.4 — 2018-02-23
- 4.4.3 — 2017-12-23
- … 78 more at https://npm.io/package/maeva/versions

## README

maeva
===

JS models. Database agnostic.

# Usage

```js
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});
```

# Client/Server architecture

`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.

## HTTP example

In your server app:

```js
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:

```js
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);
```

## Web Sockets example

In your server app:

```js
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:

```js
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);
```

# Connectors

## Most popular databases

- [maeva-firebase](https://npmjs.org/packages/maeva-firebase) FireBase connector
- [maeva-mongodb](https://npmjs.org/packages/maeva-mongodb) MongoDB connector
- [maeva-mysql](https://npmjs.org/packages/maeva-mysql) MySQL connector
- [maeva-postgresql](https://npmjs.org/packages/maeva-postgresql) PostGreSQL connector

## JavaScript databases

- [maeva-json](https://npmjs.org/packages/maeva-json) A json database that lives in memory - with an option to persist data in storage

## Client APIs

- [maeva-http](https://npmjs.org/packages/maeva-http) A built-in HTTP API you can plug to any maeva connector
- [maeva-sockets](https://npmjs.org/packages/maeva-sockets) A built-in Web Socket API you can plug to any maeva connector

# Docs

- [Guide](doc/guides/)
  - [Quick start](doc/guides/Quick%20start.md)
  - [Core concepts and design principles](doc/guides/Core%20concepts%20and%20design%20principles.md)
  - [Model](doc/guides/Model.md)
  - [Hooks](doc/guides/Hooks.md)
  - [Connect](doc/guides/Connect.md)
  - [Create your own connector](doc/guides/Create%20your%20own%20connector.md)
  - [Ids](doc/guides/Ids.md)
  - [Coding styles](doc/guides/Coding%20styles.md)
  - [Back and front ends integrations](doc/guides/Back%20and%20front%20ends%20integrations.md)
- API
  - [Actions](./doc/actions)
    - [count](./doc/actions/Count.md)
    - [findById](./doc/actions/findById.md)
    - [findByIds](./doc/actions/findByIds.md)
    - [findMany](./doc/actions/FindMany.md)
    - [findOne](./doc/actions/FindOne.md)
    - [insertMany](./doc/actions/InsertMany.md)
    - [insertOne](./doc/actions/InsertOne.md)
    - [removeById](./doc/actions/removeById.md)
    - [removeByIds](./doc/actions/removeByIds.md)
    - [removeMany](./doc/actions/RemoveMany.md)
    - [removeOne](./doc/actions/RemoveOne.md)
    - [updateById](./doc/actions/updateById.md)
    - [updateByIds](./doc/actions/updateByIds.md)
    - [updateMany](./doc/actions/UpdateMany.md)
    - [updateOne](./doc/actions/UpdateOne.md)
  - [Connections](./doc/connections)
    - [connect](./doc/connections/Connect.md)
    - [connected](./doc/connections/Connected.md)
    - [disconnect](./doc/connections/Disconnect.md)
    - [disconnected](./doc/connections/Disconnected.md)
    - [reconnect](./doc/connections/Reconnect.md)
  - Models
    - [model](./doc/guides/Model.md)
  - [Types](./doc/types)
    - [any](./doc/types/Any.md)
    - [array](./doc/types/Array.md)
    - [link](./doc/types/Link.md)
    - [mixed](./doc/types/Mixed.md)
    - [shape](./doc/types/Shape.md)
    - [tuple](./doc/types/Tuple.md)
    - [type](./doc/types/Type.md)
  - [Updaters](./doc/updaters)
    - [divide](./doc/updaters/Divide.md)
    - [subtract](./doc/updaters/Subtract.md)
    - [sum](./doc/updaters/Sum.md)
    - [times](./doc/updaters/Times.md)
  - [Values](./doc/values)
    - [above](./doc/values/Above.md)
    - [after](./doc/values/After.md)
    - [before](./doc/values/Before.md)
    - [below](./doc/values/Below.md)
    - [like](./doc/values/Like.md)
    - [match](./doc/values/Match.md)
    - [not](./doc/values/Not.md)

---
_Source: https://npm.io/package/maeva · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
