Projetos
Ver no GitHub somewhere.js
dreyacosta/somewhere.js
Sobre
Small in-memory database for Node.js that persists on disk
Dados e análiseCrescimento medido de estrelas
- em 24 h
- 0
- em 7 dias
- 0
- em 15 dias
- 0
- em 1 mês
- Coletando histórico
Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.
README.md
Originalsomewhere.js 
Small in-memory database for Node.js that persists on disk
Installation
$ npm install somewhere
Usage
Load
var Database = require('somewhere');
Create database
var onlyMemoryDb = new Database();
var memoryDiskDb = new Database('./database.json');
Database connection
var db = new Database('./database.json');
Save
db.save('collection', data);
var movie = {
title: "Die Hard",
genre: "Action",
director: "John McTiernan",
description: "John McClane, officer of the NYPD, tries to save wife Holly
Gennaro and several others, taken hostage by German terrorist Hans Gruber
during a Christmas party at the Nakatomi Plaza in Los Angeles."
};
db.save('movies', movie);
/** Result: Saved Object (autogenerated id)
{
id: "0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1",
title: "Die Hard",
genre: "Action",
director: "John McTiernan",
description: "John McClane, officer of the NYPD, tries to save wife Holly
Gennaro and several others, taken hostage by German terrorist Hans Gruber
during a Christmas party at the Nakatomi Plaza in Los Angeles."
}
*/
Find one
db.findOne('collection', query);
db.findOne('movies', { title: 'Die Hard' });
/** Result: Object
{
id: "0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1",
title: "Die Hard",
genre: "Action",
director: "John McTiernan",
description: "John McClane, officer of the NYPD, tries to save wife Holly
Gennaro and several others, taken hostage by German terrorist Hans Gruber
during a Christmas party at the Nakatomi Plaza in Los Angeles."
}
*/
Find all
db.find('movies', query);
db.find('movies', { genre: 'Action' });
/** Result: Objects array
[{
id: "0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1",
title: "Die Hard",
genre: "Action",
director: "John McTiernan",
description: "John McClane, officer of the NYPD, tries to save wife Holly
Gennaro and several others, taken hostage by German terrorist Hans Gruber
during a Christmas party at the Nakatomi Plaza in Los Angeles."
}]
*/
Update
db.update('movies', id, data);
db.update('movies', '0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1', { genre: "Action/Thriller" });
/** Result: Updated Object
{
id: "0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1",
title: "Die Hard",
genre: "Action/Thriller",
director: "John McTiernan",
description: "John McClane, officer of the NYPD, tries to save wife Holly
Gennaro and several others, taken hostage by German terrorist Hans Gruber
during a Christmas party at the Nakatomi Plaza in Los Angeles."
}
*/
Remove
db.remove('movies', id);
db.remove('movies', '0ab7d8a8-ab46-35cd-ccd4-81ccfe81c3f1');
/** Result: Boolean
true
*/
Clear database
db.clear()
License
This software is free to use under the MIT license.
Explore projetos relacionados
Carregando…