-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ricardo Gama
committed
Jun 22, 2016
1 parent
cfbfa3c
commit 66d20c6
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Changelog | ||
|
||
## [1.0.0](https://github.com/seegno/bookshelf-mask/tree/1.0.0) | ||
|
||
**Merged pull requests:** | ||
|
||
- Add initial code [\#1](https://github.com/seegno/bookshelf-mask/pull/1) ([ricardogama](https://github.com/ricardogama)) | ||
|
||
|
||
|
||
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _jsonMask = require('json-mask'); | ||
|
||
var _jsonMask2 = _interopRequireDefault(_jsonMask); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
/** | ||
* Export `bookshelf-mask` plugin. | ||
*/ | ||
|
||
exports.default = function (Bookshelf) { | ||
Bookshelf.Model = Bookshelf.Model.extend({ | ||
mask: function mask(scope, options) { | ||
return (0, _jsonMask2.default)(this.toJSON(options), this.masks && this.masks[scope] || scope); | ||
} | ||
}); | ||
|
||
Bookshelf.Collection = Bookshelf.Collection.extend({ | ||
mask: function mask(scope, options) { | ||
scope = this.model.prototype.masks && this.model.prototype.masks[scope] || scope; | ||
|
||
return this.toJSON(options).map(function (model) { | ||
return (0, _jsonMask2.default)(model, scope); | ||
}); | ||
} | ||
}); | ||
}; | ||
/** | ||
* Module dependencies. | ||
*/ |