fly63前端网

www.fly63.com

首页文章资源工具教程 栏目
  • 关于我们
  • 网站投稿
  • 赞助一下
搜索

在线工具_工作生活好帮手

打造各种简单、易用、便捷的在线工具,网友无需注册和下载安装即可使用

点击查看

关闭

提交网站

NeDB
分享
复制链接
新浪微博
QQ 好友

扫一扫分享

GitHub:https://github.com/louischatriot/nedb
网站描述:用JavaScript编写的嵌入式数据库

Other NeDB - 用JavaScript编写的嵌入式数据库。可用于Node.js, nw.js, electron和浏览器,100%JavaScript,无二进制依赖。api是MongoDB的一个子集,速度很快。


安装与测试

npm和bower上的模块名称是nedb。

npm install nedb --save    # Put latest version in your package.json
npm test                   # You'll need the dev dependencies to launch tests
bower install nedb         # For the browser versions, which will be in browser-version/out

您可以将NeDB用作仅内存数据存储或持久数据存储。一个数据存储区相当于MongoDB集合。构造函数如下使用,new Datastore(options)


例子

// Type 1: In-memory only datastore (no need to load the database)
var Datastore = require('nedb')
  , db = new Datastore();


// Type 2: Persistent datastore with manual loading
var Datastore = require('nedb')
  , db = new Datastore({ filename: 'path/to/datafile' });
db.loadDatabase(function (err) {    // Callback is optional
  // Now commands will be executed
});


// Type 3: Persistent datastore with automatic loading
var Datastore = require('nedb')
  , db = new Datastore({ filename: 'path/to/datafile', autoload: true });
// You can issue commands right away


// Type 4: Persistent datastore for a Node Webkit app called 'nwtest'
// For example on Linux, the datafile will be ~/.config/nwtest/nedb-data/something.db
var Datastore = require('nedb')
  , path = require('path')
  , db = new Datastore({ filename: path.join(require('nw.gui').App.dataPath, 'something.db') });


// Of course you can create multiple datastores if you need several
// collections. In this case it's usually a good idea to use autoload for all collections.
db = {};
db.users = new Datastore('path/to/users.db');
db.robots = new Datastore('path/to/robots.db');

// You need to load each database (here we do it asynchronously)
db.users.loadDatabase();
db.robots.loadDatabase();


链接: https://fly63.com/nav/2663

more>>
相关栏目
Express
基于 Node.js 平台,快速、开放、极简的 web 开发框架
官网GitHub
pm2
pm2 是一个带有负载均衡功能的Node应用的进程管理器
官网GitHub
Koa
基于 Node.js 平台的下一代 web 开发框架
官网GitHub
Egg.js
为企业级框架和应用而生
官网GitHub
Primus
通用包装器实时框架
点击进入GitHub
Electrode
一个用于构建通用 React / Node.js 应用程序的平台
点击进入GitHub
faye-websocket
Node.js 应用程序中命令预先存在的 WebSocket 连接
点击进入GitHub
vm2
一个Node.js 官方 vm 库的替代品
点击进入GitHub
node-opencv
node视觉算法库
官网GitHub
node-xml2js
Json与xml相互转化的工具
点击进入GitHub
node-red
一套开源可视化界面开发工具
官网GitHub
polemo
网易开源的游戏后端框架
点击进入GitHub
AdonisJs
一款类似laravel的node.js框架
官网GitHub
GitBook
基于 Node.js 的命令行工具,可使用 Github/Git 和 Markdown 来制作精美的电子书。
官网
nodebestpractices
NodeJS最佳实践
官网GitHub
Inquirer.js
NodeJs交互式命令行工具
点击进入GitHub

手机预览