Skip to content

Commit 24e6985

Browse files
Initial commit.
0 parents  commit 24e6985

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed

.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# Compiled binary addons (http://nodejs.org/api/addons.html)
20+
build/Release
21+
22+
# Dependency directory
23+
# Deployed apps should consider commenting this line out:
24+
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
25+
node_modules

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 npmawesome.com
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# example-nedb
2+
3+
This example refers to the article on [nodejitsu.com](http://blog.nodejitsu.com/) and [npmawesome.com](http://npmawesome.com/) about `nedb`.
4+
5+
## Usage
6+
7+
git clone https://github.com/npmawesome/example-nedb
8+
cd example-nedb
9+
npm install
10+
npm test
11+
12+
## License
13+
14+
MIT

index.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* example-nedb
3+
* http://npmawesome.com/posts/nedb
4+
*
5+
* Copyright(c) 2015 npmawesome.com
6+
*
7+
* MIT Licensed
8+
*/
9+
10+
var Datastore = require('nedb');
11+
var db = new Datastore({ filename: __dirname + '/db.json', autoload: true });
12+
13+
db.findOne({ _id: 1 }, function (err, doc) {
14+
doc = doc || { _id: 1, counter: 0 };
15+
16+
console.log('This example was executed ' + doc.counter + ' times. Last access time was ' + doc.lastSeetAt);
17+
18+
doc.lastSeetAt = new Date();
19+
doc.counter++;
20+
21+
db.update({ _id: 1 }, doc, { upsert: true }, function (err, num) {
22+
console.log('Updated ' + num + ' records');
23+
});
24+
});

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "example-nedb",
3+
"version": "1.0.0",
4+
"description": "Example which describes how to use the nedb module.",
5+
"license": "MIT",
6+
"scripts": {
7+
"test": "node index.js"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/npmawesome/example-nedb"
12+
},
13+
"dependencies": {
14+
"nedb": "^1.1.1"
15+
}
16+
}

0 commit comments

Comments
 (0)