Socket
Socket
Sign inDemoInstall

lowdb

Package Overview
Dependencies
2
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

lowdb


Version published
Maintainers
1
Created

Package description

What is lowdb?

Lowdb is a small local JSON database for Node, Electron, and the browser. It's a simple and lightweight way to store data locally using a JSON file. It is ideal for small projects, quick prototypes, and applications that do not require a full-fledged database.

What are lowdb's main functionalities?

Create and Read Data

This feature allows you to create and read data from a JSON file. The code initializes a lowdb instance, sets default values, adds a new post, and retrieves it.

const low = require('lowdb');
const FileSync = require('lowdb/adapters/FileSync');

const adapter = new FileSync('db.json');
const db = low(adapter);

db.defaults({ posts: [] }).write();

db.get('posts').push({ id: 1, title: 'lowdb is awesome' }).write();

const post = db.get('posts').find({ id: 1 }).value();
console.log(post);

Update Data

This feature allows you to update existing data in the JSON file. The code updates the title of the post with id 1 and retrieves the updated post.

db.get('posts').find({ id: 1 }).assign({ title: 'lowdb is super awesome' }).write();
const updatedPost = db.get('posts').find({ id: 1 }).value();
console.log(updatedPost);

Delete Data

This feature allows you to delete data from the JSON file. The code removes the post with id 1 and retrieves the remaining posts.

db.get('posts').remove({ id: 1 }).write();
const posts = db.get('posts').value();
console.log(posts);

Other packages similar to lowdb

Readme

Source

low

NPM version

Example

$ npm i lowdb --save
var low = require('lowdb');

// insert a song
low('songs').insert({title: 'low!'});

// find all songs named 'low!'
var songs = low('songs').where({title: 'low!'}).value();

Database is saved to db.json.

API

See Underscore.db and Lo-Dash.

Keywords

FAQs

Last updated on 02 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc