用于 Node.js 的轻量级 Javascript DB

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7233057/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 01:25:27  来源:igfitidea点击:

Lightweight Javascript DB for use in Node.js

javascriptdatabasekey-value-store

提问by ConfusedNoob

Anybody know of a lightweight yet durable database, written in Javascript, that can be used with Node.js.

任何人都知道用 Javascript 编写的轻量级但持久的数据库,可以与 Node.js 一起使用。

I don't want the 'weight' of (great) solutions like Mongo or Couch. A simple, in memory JS database with the capability to persist to disk as a file would be enough. I would only use it to store small amounts of data.

我不想要像 Mongo 或 Couch 这样的(伟大的)解决方案的“重量”。一个简单的内存 JS 数据库能够作为文件持久化到磁盘就足够了。我只会用它来存储少量数据。

Requirements:

要求:

  • can run in process with a node.js server application
  • can save the whole database to disk and recover after a failure
  • NO need for atomic writes or transaction supports
  • fast queries and sorting would be nice
  • only needs to support small data volumes, up to 1MB in total
  • 可以与 node.js 服务器应用程序一起运行
  • 可以将整个数据库保存到磁盘并在失败后恢复
  • 不需要原子写入或事务支持
  • 快速查询和排序会很好
  • 只需要支持小数据量,总共最大1MB

I've come across TAFFY db so far but it really doesn't seem optimized for use in Node.js. Anybody seen what I'm looking for out there?

到目前为止,我遇到了 TAFFY db,但它似乎并没有针对在 Node.js 中使用进行优化。有人看到我在外面寻找什么吗?

Thanks

谢谢

采纳答案by Steve

I'm only familiar with Mongo and Couch, but there's also one named Persistence.

我只熟悉 Mongo 和 Couch,但也有一个名为Persistence 的

回答by Louis Chatriot

I had the same requirements as you but couldn't find a suitable database. nStore was promising but the API was not nearly complete enough and not very coherent.

我和你有同样的要求,但找不到合适的数据库。nStore 很有前途,但 API 还不够完整,也不是很连贯。

That's why I made NeDB, which a dependency-less embedded database for Node.js projects. You can use it with a simple require(), it is persistent, and its API is the most commonly used subset of the very well-known MongoDB API.

这就是我制作NeDB的原因,它是一个用于 Node.js 项目的无依赖嵌入式数据库。您可以将它与简单的 一起使用require(),它是持久的,并且它的 API 是非常著名的 MongoDB API 中最常用的子集。

https://github.com/louischatriot/nedb

https://github.com/louischatriot/nedb

回答by Christof Jans

NeDBseems to be what you are looking for. From the blurb:

NeDB似乎正是您要找的。从简介:

Embedded persistent database for Node.js, written in Javascript, with no dependency (except npm modules of course). You can think of it as a SQLite for Node.js projects, which can be used with a simple require statement. The API is a subset of MongoDB's. You can use it as a persistent or an in-memory only datastore.

Node.js 的嵌入式持久数据库,用 Javascript 编写,没有依赖性(当然 npm 模块除外)。您可以将其视为 Node.js 项目的 SQLite,可以与简单的 require 语句一起使用。API 是 MongoDB 的一个子集。您可以将其用作持久或仅内存中的数据存储。

回答by Damodaran

Lokijs: A fast, in-memory document-oriented datastore for node.js, browser and cordova.

Lokijs:一个用于 node.js、浏览器和cordova 的快速、内存中面向文档的数据存储。

  • In-memory Javascript Datastore wih Persistence
  • In-Browser NoSQL db with syncing and persisting
  • a Redis-style store an npm install away
  • Persistable NoSQL db for Cordova
  • Embeddable NoSQL db with Persistence for node-webkit
  • 具有持久性的内存 Javascript 数据存储
  • 具有同步和持久化功能的浏览器内 NoSQL 数据库
  • 一个 Redis 风格的存储一个 npm 安装
  • Cordova 的持久 NoSQL 数据库
  • 具有持久性的可嵌入 NoSQL 数据库,用于 node-webkit

LokiJS to be the ideal solution:

LokiJS 是理想的解决方案:

  • Mobile applications - especially HTML5 based (Cordova, Phonegap, etc.)
  • Node.js embedded datastore for small-to-medium apps
  • Embedded in desktop application with Node Webkit
  • 移动应用程序——尤其是基于 HTML5 的(Cordova、Phonegap 等)
  • 用于中小型应用程序的 Node.js 嵌入式数据存储
  • 使用 Node Webkit 嵌入桌面应用程序

https://github.com/techfort/LokiJS

https://github.com/techfort/LokiJS

回答by Sergey Korotkov

Take a look at http://www.tingodb.com. I believe it does what you looking for. Additionally it fully compatible with MongoDB API. This reduces implementation risks and gives you option to switch to heavy solution as your app grows.

看看http://www.tingodb.com。我相信它可以满足您的需求。此外,它与 MongoDB API 完全兼容。这降低了实施风险,并让您可以选择随着应用程序的增长而切换到重型解决方案。

https://github.com/sergeyksv/tingodb

https://github.com/sergeyksv/tingodb

回答by Guy Korland

Try nStore, it seems like a nice key/value lightweight dembedded db for node. See https://github.com/creationix/nstore

试试 nStore,它似乎是一个很好的键/值轻量级节点嵌入数据库。见https://github.com/creationix/nstore

回答by Radek

I had trouble with SQLite3, nStore and Alfred.

我在使用 SQLite3、nStore 和 Alfred 时遇到了麻烦。

What works for me is node-dirty:

对我有用的是node-dirty

path = "#{__dirname}/data/messages.json"
messages = db path

message = 'text': 'Lorem ipsum dolor sit...'

messages.on "load", ->    
    messages.set 'my-unique-key', message, ->
        console.log messages.get('my-unique-key').text

    messages.forEach (key, value) ->
        console.log "Found key: #{key}, val: %j", value

messages.on "drain", ->
    console.log "Saved to #{path}"

回答by user2870483

LevelUP aims to expose the features of LevelDB in a Node.js-friendly way.

LevelUP 旨在以 Node.js 友好的方式公开 LevelDB 的功能。

https://github.com/rvagg/node-levelup

https://github.com/rvagg/node-levelup

You can also look at UnQLite. with a node.js binding node-unqlite

你也可以看看 UnQLite。使用 node.js 绑定 node-unqlite

https://github.com/symisc/unqlite

https://github.com/symisc/unqlite

回答by Wael Boutglay

Maybe you should try LocallyDBit's easy-to-use and lightweight in addition to the with advanced selecting system similar to javascript conditional expression...

也许您应该尝试使用LocallyDB,它除了具有类似于 javascript 条件表达式的高级选择系统之外,还易于使用且轻量级...

https://github.com/btwael/locallydb

https://github.com/btwael/locallydb

回答by John McLear