Skip to content

Commit

Permalink
7.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Aug 1, 2018
1 parent deb5935 commit 7afcf34
Show file tree
Hide file tree
Showing 32 changed files with 184 additions and 108 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog


### 7.X.X (comming soon)
### 7.7.1 (August 1, 2018)

Bugfixes:
- newRxError is not a constructor [#719](https://github.com/pubkey/rxdb/issues/719) thanks [@errorx666](https://github.com/errorx666)
Expand Down
2 changes: 1 addition & 1 deletion dist/es/plugins/schema-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function checkFieldNameRegex(fieldName) {
});
}

var regexStr = '^[a-zA-Z][[a-zA-Z0-9_]*]?[a-zA-Z0-9]$';
var regexStr = '^[a-zA-Z](?:[[a-zA-Z0-9_]*]?[a-zA-Z0-9])?$';
var regex = new RegExp(regexStr);
if (!fieldName.match(regex)) {
throw RxError.newRxError('SC1', {
Expand Down
11 changes: 9 additions & 2 deletions dist/es/plugins/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import _asyncToGenerator from 'babel-runtime/helpers/asyncToGenerator';
*/
import modifyjs from 'modifyjs';
import deepEqual from 'deep-equal';
import { clone } from '../util.js';

export function update(updateObj) {
var _this = this;

var oldDocData = clone(this._data);
var newDoc = modifyjs(this._data, updateObj);

Object.keys(this._data).forEach(function (previousPropName) {
if (newDoc[previousPropName]) {
// if we don't check inequality, it triggers an update attempt on fields that didn't really change,
Expand All @@ -28,7 +29,13 @@ export function update(updateObj) {
return _this._data[newPropName] = newDoc[newPropName];
});

return this.save();
return this.save().then(function () {
return _this;
})['catch'](function (err) {
// save was not successfull, reset doc-data
_this._data = oldDocData;
throw err;
});
}

export var RxQueryUpdate = function () {
Expand Down
4 changes: 2 additions & 2 deletions dist/es/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ export function validateCouchDBString(name) {
name.includes('\\') // windows
) return true;

var regStr = '^[a-z][a-z0-9]*$';
var regStr = '^[a-z][_$a-z0-9]*$';
var reg = new RegExp(regStr);
if (!name.match(reg)) {
throw new RxError.newRxError('UT2', {
throw RxError.newRxError('UT2', {
regex: regStr,
givenName: name
});
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/plugins/schema-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function checkFieldNameRegex(fieldName) {
});
}

var regexStr = '^[a-zA-Z][[a-zA-Z0-9_]*]?[a-zA-Z0-9]$';
var regexStr = '^[a-zA-Z](?:[[a-zA-Z0-9_]*]?[a-zA-Z0-9])?$';
var regex = new RegExp(regexStr);
if (!fieldName.match(regex)) {
throw _rxError2['default'].newRxError('SC1', {
Expand Down
24 changes: 15 additions & 9 deletions dist/lib/plugins/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,15 @@ var _deepEqual = require('deep-equal');

var _deepEqual2 = _interopRequireDefault(_deepEqual);

var _util = require('../util.js');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

/**
* this plugin allows delta-updates with mongo-like-syntax
* It's using modifyjs internally
* @link https://github.com/lgandecki/modifyjs
*/
function update(updateObj) {
var _this = this;

var oldDocData = (0, _util.clone)(this._data);
var newDoc = (0, _modifyjs2['default'])(this._data, updateObj);

Object.keys(this._data).forEach(function (previousPropName) {
if (newDoc[previousPropName]) {
// if we don't check inequality, it triggers an update attempt on fields that didn't really change,
Expand All @@ -105,9 +102,18 @@ function update(updateObj) {
return _this._data[newPropName] = newDoc[newPropName];
});

return this.save();
}

return this.save().then(function () {
return _this;
})['catch'](function (err) {
// save was not successfull, reset doc-data
_this._data = oldDocData;
throw err;
});
} /**
* this plugin allows delta-updates with mongo-like-syntax
* It's using modifyjs internally
* @link https://github.com/lgandecki/modifyjs
*/
var rxdb = exports.rxdb = true;
var prototypes = exports.prototypes = {
RxDocument: function RxDocument(proto) {
Expand Down
4 changes: 2 additions & 2 deletions dist/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ function validateCouchDBString(name) {
name.includes('\\') // windows
) return true;

var regStr = '^[a-z][a-z0-9]*$';
var regStr = '^[a-z][_$a-z0-9]*$';
var reg = new RegExp(regStr);
if (!name.match(reg)) {
throw new _rxError2['default'].newRxError('UT2', {
throw _rxError2['default'].newRxError('UT2', {
regex: regStr,
givenName: name
});
Expand Down
Loading

0 comments on commit 7afcf34

Please sign in to comment.