Socket
Socket
Sign inDemoInstall

lowdb

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lowdb - npm Package Compare versions

Comparing version 0.13.0-beta.3 to 0.13.0-beta.4

dist/lowdb-localstorage.js

31

examples/README.md

@@ -8,7 +8,8 @@ # Examples

const low = require('lowdb')
const db = low('db.json')
const posts = db.get('posts', [])
const result = posts
db.defauls({ posts: [] })
.value()
const result = db.get('posts')
.push({ name: process.argv[2] })

@@ -29,8 +30,9 @@ .value()

import low from 'lowdb'
const db = low('db')
const posts = db.get('posts', [])
db.defauls({ posts: [] })
.value()
// Data is automatically saved to localStorage
posts
db.get('posts')
.push({ title: 'lowdb' })

@@ -42,3 +44,3 @@ .value()

Please __note__ that for local server with no concurrent requests, it's often easier to use lowdb with `file-sync` storage which is the default.
Please __note__ that if you're developing a local server and don't expect to get concurrent requests, it's often easier to use `file-sync` storage, which is the default.

@@ -60,4 +62,8 @@ But if you need to avoid blocking requests, you can do so by using `file-async` storage.

// Init
db.defauls({ posts: [] })
.value()
// Define posts
const posts = db.get('posts', [])
const posts = db.get('posts')

@@ -122,3 +128,6 @@ // Routes

db.get('posts', [])
db.defauls({ posts: [] })
.value()
db.get('posts')
.push({ title: 'lowdb' })

@@ -128,5 +137,5 @@ .value()

// Manual writing
fs.writeFileSync('db.json', JSON.stringify(db.data()))
fs.writeFileSync('db.json', JSON.stringify(db.getState()))
```
In this case, you may want to consider creating a custom storage instead.
In this case, it's recommended to create a custom storage.

@@ -7,7 +7,2 @@ 'use strict';

// const defaultOptions = {
// storage: defaultStorage,
// writeOnChange: true
// }
function low(source) {

@@ -14,0 +9,0 @@ var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

{
"name": "lowdb",
"version": "0.13.0-beta.3",
"description": "JSON database for Node and the browser powered by lodash",
"version": "0.13.0-beta.4",
"description": "JSON database for Node and the browser powered by lodash API",
"keywords": [

@@ -10,2 +10,3 @@ "flat",

"database",
"storage",
"JSON",

@@ -17,4 +18,3 @@ "lo-dash",

"embed",
"embeddable",
"extendable"
"embeddable"
],

@@ -28,4 +28,4 @@ "main": "./lib",

"babel": "babel src --out-dir lib --ignore dist.js",
"umd": "webpack src/dist.js dist/lowdb.js --output-library low",
"min": "webpack -p src/dist.js dist/lowdb.min.js --output-library low"
"umd": "webpack src/index.js dist/lowdb.js --output-library low",
"min": "webpack -p src/index.js dist/lowdb.min.js --output-library low"
},

@@ -57,3 +57,4 @@ "repository": {

"babel-preset-stage-3": "^6.3.13",
"husky": "^0.11.0",
"husky": "^0.11.4",
"lodash": "^4.12.0",
"sinon": "^1.17.2",

@@ -64,3 +65,3 @@ "standard": "^4.0.1",

"tempfile": "^1.1.1",
"underscore-db": "^0.9.0",
"underscore-db": "^0.10.0",
"webpack": "^1.12.13"

@@ -72,2 +73,3 @@ },

"browser": {
"lodash": false,
"./src/file-sync.js": "./src/browser.js",

@@ -74,0 +76,0 @@ "./lib/file-sync.js": "./lib/browser.js"

@@ -17,6 +17,2 @@ # Lowdb [![NPM version](https://badge.fury.io/js/lowdb.svg)](http://badge.fury.io/js/lowdb) [![Build Status](https://travis-ci.org/typicode/lowdb.svg?branch=master)](https://travis-ci.org/typicode/lowdb)

db.get('posts')
.find({ id: 1 })
.value()
db.set('user.name', 'typicode')

@@ -26,3 +22,3 @@ .value()

Data is __automatically__ saved to `db.json`.
Data is __automatically__ saved to `db.json`

@@ -40,2 +36,10 @@ ```json

And you can query it using lodash API
```js
db.get('posts')
.find({ id: 1 })
.value()
```
Lowdb is perfect for CLIs, small servers, Electron apps and npm packages in general.

@@ -66,6 +70,6 @@

A standalone UMD build is also available on [npmcdn](https://npmcdn.com/) for testing and quick prototyping:
A UMD build is also available on [npmcdn](https://npmcdn.com/) for testing and quick prototyping:
```html
<script src="http://npmcdn.com/lodash/dist/lodash.min.js"></script>
<script src="https://npmcdn.com/lodash@4/lodash.min.js"></script>
<script src="http://npmcdn.com/lowdb/dist/lowdb.min.js"></script>

@@ -91,4 +95,6 @@ <script>

Creates a database instance. Use options to configure lowdb, here are some examples:
Creates a __lodash chain__, you can use __any__ lodash method on it.
Use `options` to configure how lowdb should persist data. Here are some examples:
```js

@@ -146,5 +152,5 @@ // in-memory

__db.setState()__
__db.setState(newState)__
You can use it to drop database or replace it with a new object. New state will be automatically persisted.
Use it to drop database or set a new state (database will be automatically persisted).

@@ -212,3 +218,3 @@ ```js

Retrieve post titles.
Get post titles.

@@ -236,4 +242,3 @@ ```js

```js
db('posts')
.chain()
db.get('posts')
.find({ title: 'low!' })

@@ -247,3 +252,5 @@ .assign({ title: 'hi!'})

```js
db.get('posts').remove({ title: 'low!' })
db.get('posts')
.remove({ title: 'low!' })
.value()
```

@@ -253,3 +260,3 @@

Being able to retrieve data using an id can be quite useful, particularly in servers. To add id-based resources support to lowdb, you have 2 options.
Being able to get data using an id can be quite useful, particularly in servers. To add id-based resources support to lowdb, you have 2 options.

@@ -283,3 +290,3 @@ [underscore-db](https://github.com/typicode/underscore-db) provides a set of helpers for creating and manipulating id-based resources.

read: (source, deserialize) => // must return an object or a Promise
write: (dest, obj, serialize) => // must return undefined or a Promise
write: (source, obj, serialize) => // must return undefined or a Promise
}

@@ -286,0 +293,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc