Skip to content

Commit 58e6345

Browse files
committed
Use _.has
1 parent 44b3c42 commit 58e6345

File tree

7 files changed

+15
-58
lines changed

7 files changed

+15
-58
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
language: node_js
22
node_js:
33
- "stable"
4-
- "6"
5-
- "5"
6-
- "4"
74
- "0.12"
85
- "0.10"

README.md

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# underscore-db [![Build Status](https://travis-ci.org/typicode/underscore-db.svg)](https://travis-ci.org/typicode/underscore-db) [![NPM version](https://badge.fury.io/js/underscore-db.svg)](http://badge.fury.io/js/underscore-db)
22

3-
> Adds functions to Underscore/Lo-Dash for manipulating database-like objects.
3+
> Adds functions to Underscore/Lodash for manipulating database-like objects.
44
55
It adds:
66
* `getById`
@@ -19,35 +19,25 @@ Data can be persisted using the filesystem or localStorage.
1919

2020
__[Live example](http://typicode.github.io/underscore-db/)__
2121

22-
__Tip__ You can extend [LowDB](https://github.com/typicode/lowdb) with underscore-db.
22+
__Tip__ You can extend [lowdb](https://github.com/typicode/lowdb) with underscore-db.
2323

2424
## Install
2525

2626
__Node__
2727

2828
```bash
29-
$ npm install underscore underscore-db
29+
$ npm install lodash underscore-db
3030
```
3131

3232
```javascript
33-
var _ = require('underscore');
33+
var _ = require('lodash');
3434
var _db = require('underscore-db');
3535

3636
_.mixin(_db);
3737
```
3838

39-
__Browser__
39+
__Tip__ underscore-db is also compatible with underscore
4040

41-
```bash
42-
$ bower install underscore underscore-db
43-
```
44-
45-
```html
46-
<script src="underscore.js" type="text/javascript"></script>
47-
<script src="underscore-db.js" type="text/javascript"></script>
48-
```
49-
50-
To use underscore-db with Lo-Dash, just replace `underscore` with `lodash`
5141

5242
## Usage example
5343

@@ -228,9 +218,9 @@ _.createId = function(collectionName, doc) {
228218

229219
### How to query?
230220

231-
Everything you need for querying is present in Underscore and Lo-Dash: `where`, ```find```, ```map```, ```reduce```, ```filter```, ```reject```, ```sortBy```, ```groupBy```, ```countBy```, ...
221+
Everything you need for querying is present in Underscore and Lodash: `where`, ```find```, ```map```, ```reduce```, ```filter```, ```reject```, ```sortBy```, ```groupBy```, ```countBy```, ...
232222

233-
See http://underscorejs.org/ or http://lodash.com/docs.
223+
See http://lodash.com/docs or http://underscorejs.org.
234224

235225
Example:
236226

@@ -245,7 +235,7 @@ var topFivePosts = _(db.posts)
245235
.first(5)
246236
.value();
247237

248-
// Using Lo-Dash
238+
// Using Lodash
249239
var topFivePosts = _(db.posts)
250240
.where({published: true})
251241
.sortBy('views')
@@ -255,13 +245,12 @@ var topFivePosts = _(db.posts)
255245

256246
### How to reduce file size?
257247

258-
With Lo-Dash, you can create custom builds and include just what you need.
248+
With Lodash, you can create custom builds and include just what you need.
259249

260-
Minimal build for underscore-db to work (~2kb min gzipped):
261250

262251
```bash
263252
$ npm install -g lodash-cli
264-
$ lodash underscore include=find,where,forEach,indexOf
253+
$ lodash include=find,forEach,indexOf,filter,has
265254
```
266255

267256
For more build options, see http://lodash.com/custom-builds.

bower.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

dist/underscore-db.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = {
4848
getById: function(collection, id) {
4949
var self = this;
5050
return this.find(collection, function(doc) {
51-
if (doc.hasOwnProperty(self.__id())) {
51+
if (self.has(doc, self.__id())) {
5252
return doc[self.__id()].toString() === id.toString();
5353
}
5454
});

dist/underscore-db.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "underscore-db",
3-
"version": "0.12.0",
3+
"version": "0.12.1",
44
"description": "Use JavaScript objects as databases",
55
"main": "src/node.js",
66
"scripts": {

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333
getById: function(collection, id) {
3434
var self = this;
3535
return this.find(collection, function(doc) {
36-
if (doc.hasOwnProperty(self.__id())) {
36+
if (self.has(doc, self.__id())) {
3737
return doc[self.__id()].toString() === id.toString();
3838
}
3939
});

0 commit comments

Comments
 (0)