All Projects → flosse → Json File Store

flosse / Json File Store

Licence: mit
A simple JSON store for Node.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Json File Store

Jsome
✨ Make your JSON look AWESOME
Stars: ✭ 179 (-3.76%)
Mutual labels:  json
Circe
Yet another JSON library for Scala
Stars: ✭ 2,223 (+1095.16%)
Mutual labels:  json
License List Data
Various data formats for the SPDX License List including RDFa, HTML, Text, and JSON
Stars: ✭ 182 (-2.15%)
Mutual labels:  json
Bancosbrasileiros
Lista de bancos brasileiros | Brazilian banks list
Stars: ✭ 178 (-4.3%)
Mutual labels:  json
Gaia
DEPRECATED - Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see
Stars: ✭ 2,091 (+1024.19%)
Mutual labels:  unmaintained
Wpthumb
⚠️ UNMAINTAINED ⚠️ On demand image resizing for WordPress
Stars: ✭ 181 (-2.69%)
Mutual labels:  unmaintained
Json Stringify Pretty Compact
The best of both `JSON.stringify(obj)` and `JSON.stringify(obj, null, indent)`.
Stars: ✭ 177 (-4.84%)
Mutual labels:  json
Sparkliner
Sparkliner — easy way to make sparkline graph [Sketch plugin]
Stars: ✭ 184 (-1.08%)
Mutual labels:  json
Json C
https://github.com/json-c/json-c is the official code repository for json-c. See the wiki for release tarballs for download. API docs at http://json-c.github.io/json-c/
Stars: ✭ 2,313 (+1143.55%)
Mutual labels:  json
Application Insights Workbooks
Templates for Azure Monitor Workbooks
Stars: ✭ 180 (-3.23%)
Mutual labels:  json
Emuto
manipulate JSON files
Stars: ✭ 180 (-3.23%)
Mutual labels:  json
Zson
专为测试人员打造的JSON解析器
Stars: ✭ 181 (-2.69%)
Mutual labels:  json
Feed Module
Everyone deserves RSS, ATOM and JSON feeds!
Stars: ✭ 182 (-2.15%)
Mutual labels:  json
Play Json Derived Codecs
Stars: ✭ 179 (-3.76%)
Mutual labels:  json
Stubbornjava
Unconventional Java code for building web servers / services without a framework. Think dropwizard but as a seed project instead of a framework. If this project had a theme it would be break the rules but be mindful of your decisions.
Stars: ✭ 184 (-1.08%)
Mutual labels:  json
Jsons
🐍 A Python lib for (de)serializing Python objects to/from JSON
Stars: ✭ 178 (-4.3%)
Mutual labels:  json
Mozdef
DEPRECATED - MozDef: Mozilla Enterprise Defense Platform
Stars: ✭ 2,164 (+1063.44%)
Mutual labels:  unmaintained
Dalsoft.restclient
The C# REST Client - the only REST/ HTTP Client you will ever need
Stars: ✭ 185 (-0.54%)
Mutual labels:  json
Kazaam
Arbitrary transformations of JSON in Golang
Stars: ✭ 184 (-1.08%)
Mutual labels:  json
Go init
一个用go组织项目结构,主要包括 gin, goredis, gorm, websocket, rabbitmq等。👉
Stars: ✭ 183 (-1.61%)
Mutual labels:  json

JSON file store

A simple JSON file store for node.js.

Build Status Dependency Status NPM version License

WARNING: Don't use it if you want to persist a large amount of objects. Use a real DB instead.

Install

npm install jfs --save

Usage

var Store = require("jfs");
var db = new Store("data");

var d = {
  foo: "bar"
};

// save with custom ID
db.save("anId", d, function(err){
  // now the data is stored in the file data/anId.json
});

// save with generated ID
db.save(d, function(err, id){
  // id is a unique ID
});

// save synchronously
var id = db.saveSync("anId", d);

db.get("anId", function(err, obj){
  // obj = { foo: "bar" }
})

// pretty print file content
var prettyDB = new Store("data",{pretty:true});
var id = prettyDB.saveSync({foo:{bar:"baz"}});
// now the file content is formated in this way:
{
  "foo": {
    "bar": "baz"
  }
}
// instead of this:
{"foo":{"bar":"baz"}}

// get synchronously
var obj = db.getSync("anId");

// get all available objects
db.all(function(err, objs){
  // objs is a map: ID => OBJECT
});

// get all synchronously
var objs = db.allSync()

// delete by ID
db.delete("myId", function(err){
  // the file data/myId.json was removed
});

// delete synchronously
db.delete("myId");

Single file DB

If you want to store all objects in a single file, set the type option to single:

var db = new Store("data",{type:'single'});

or point to a JSON file:

var db = new Store("./path/to/data.json");

In memory DB

If you don't want to persist your data, you can set type to memory:

var db = new Store("data",{type:'memory'});

ID storage

By default the ID is not stored within your object. If you like, you can change that behavior by setting saveId to true or a custom ID

var db = new Store("data",{saveId:'myKey'});

custom ID generator

We use uuid v4 for ID generation if you don't pass an id when save a data. If you want, you can pass custom generator.

var i = 0;
var db = new Store("data",{
  idGenerator: function() {
    i = i + 1;
    return i;
  }
});

Tests

npm test

License

This project is licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].