Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/3axap4ehko/redised
https://github.com/3axap4ehko/redised
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/3axap4ehko/redised
- Owner: 3axap4eHko
- Created: 2017-11-04T20:03:51.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-06T15:22:59.000Z (about 7 years ago)
- Last Synced: 2024-04-26T14:22:20.475Z (7 months ago)
- Language: JavaScript
- Size: 43 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# REDISed
Redis based Database
[![build status](https://travis-ci.org/3axap4eHko/redised.svg?branch=master)](https://travis-ci.org/3axap4eHko/redised)## Usage
``` javascript
const { Schema, Model, createClient } = require('redised');const client = createClient();
// await redis connection
await client.connection;// drop all existing data
await db.drop();// create schema
const schema = Schema({
id: Number,
zip: { type: Number, index: true },
country: { type: String, index: true },
city: { type: String, index: true },
address: String,
});// create model
const Address = Model('address', schema);// create entity
const adress1 = Adress.create({
id: 1,
zip: 10029,
country: 'USA',
state: 'NY',
city: 'New York',
address: '1291 5th Ave',
});// save address
Address.set(adress1);
// get address by id
Address.get(address1.id);
// find all addresses in cities New York
Address.find({ city: 'New York' });// close connection
db.close();
```## Model API
- create(data) - create a Model entity
- get(id) - get entity by id
- getMany(ids) - get entities by their ids
- find(query) - find entities with defined fields values
- set(entity) - add or update entity
- setMany(entities) - add or update multiple entities
- del(...id) - delete entities by their ids
## LicenseLicense [The MIT License](http://opensource.org/licenses/MIT)
Copyright (c) 2017-present Ivan Zakharchenko