Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Stable Version 0.10.0.
Browse files Browse the repository at this point in the history
For Model.filter and Model.getAll softDeleted items are no longer returned unless the withDeleted option is set to true.
  • Loading branch information
jmdobry committed Feb 14, 2014
1 parent 5441b4b commit 9871723
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/model/static/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ function _filter(predicate, options) {

return Promise.resolve().then(function _filterInner() {

if (!('withDeleted' in options)) {
options.withDeleted = false;
}

if (!utils.isEmpty(predicate.where)) {
query = query.filter(predicate.where);
}

if (Model.softDelete && !options.withDeleted) {
query = query.filter({ deleted: null });
}

if (predicate.orderBy) {
if (utils.isString(predicate.orderBy)) {
predicate.orderBy = [
Expand Down Expand Up @@ -147,6 +155,7 @@ function _filter(predicate, options) {
* @param {object=} options Optional configuration. Properties:
*
* - `{boolean=false}` - `raw`- If `true`, return the raw data instead of instances of Model.
* - `{boolean=false}` - `withDeleted`- If `true`, return "softDeleted" items as well.
*
* @param {function=} cb Optional callback function for Node-style usage. Signature: `cb(err, instances)`. Arguments:
*
Expand Down
9 changes: 9 additions & 0 deletions lib/model/static/getAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var utils = require('../../support/utils'),
* @param {object=} options Optional configuration. Properties:
*
* - `{boolean=false}` - `raw`- If `true`, return the raw data instead of instances of Model.
* - `{boolean=false}` - `withDeleted`- If `true`, return "softDeleted" items as well.
*
* @param {function=} cb Optional callback function for Node-style usage. Signature: `cb(err, instances)`. Arguments:
*
Expand Down Expand Up @@ -100,10 +101,18 @@ module.exports = function getAll(keys, index, options, cb) {
throw new IllegalArgumentError(errorPrefix + 'options: Must be an object!', { actual: typeof options, expected: 'object' });
}

if (!('withDeleted' in options)) {
options.withDeleted = false;
}

keys.push(index);

query.getAll.apply(query, keys);

if (Model.softDelete && !options.withDeleted) {
query = query.filter({ deleted: null });
}

return Model.connection.run(query, options).then(function (cursor) {
var deferred = Promise.defer();

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "reheat",
"description": "A red hot Node.js ORM for RethinkDB.",
"version": "0.9.0",
"version": "0.10.0",
"homepage": "https://github.com/jmdobry/reheat",
"repository": {
"type": "git",
Expand Down

1 comment on commit 9871723

@jmdobry
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#16

Please sign in to comment.