Skip to content

Commit

Permalink
[Release] 0.34.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kiaking committed Nov 26, 2019
1 parent 2b3a135 commit aabe326
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 56 deletions.
41 changes: 23 additions & 18 deletions dist/vuex-orm.common.js
Expand Up @@ -671,7 +671,9 @@ function pickBy(object, predicate) {
function orderBy(collection, keys, directions) {
var index = -1;
var result = collection.map(function (value) {
var criteria = keys.map(function (key) { return value[key]; });
var criteria = keys.map(function (key) {
return typeof key === 'function' ? key(value) : value[key];
});
return { criteria: criteria, index: ++index, value: value };
});
return baseSortBy(result, function (object, other) {
Expand Down Expand Up @@ -2662,14 +2664,13 @@ var Model = /** @class */ (function () {
* be filled with its default value defined at model fields definition.
*/
Model.prototype.$fill = function (record) {
var _this = this;
var data = record || {};
var fields = this.$fields();
Object.keys(fields).forEach(function (key) {
for (var key in fields) {
var field = fields[key];
var value = data[key];
_this[key] = field.make(value, data, key);
});
this[key] = field.make(value, data, key);
}
};
/**
* Serialize field values into json.
Expand Down Expand Up @@ -3489,7 +3490,7 @@ var OrderByFilter = /** @class */ (function () {
if (query.orders.length === 0) {
return records;
}
var keys = query.orders.map(function (order) { return order.field; });
var keys = query.orders.map(function (order) { return order.key; });
var directions = query.orders.map(function (order) { return order.direction; });
return Utils.orderBy(records, keys, directions);
};
Expand Down Expand Up @@ -3954,17 +3955,15 @@ var Query = /** @class */ (function () {
return this.get();
};
/**
* Get the record of the given id.
* Find the record by the given id.
*/
Query.prototype.find = function (id) {
id = Array.isArray(id) ? JSON.stringify(id) : id;
var record = this.state.data[id];
var indexId = Array.isArray(id) ? JSON.stringify(id) : id;
var record = this.state.data[indexId];
if (!record) {
return null;
}
var model = this.hydrate(record);
model.$id = String(id);
return this.item(model);
return this.item(this.hydrate(record));
};
/**
* Get the record of the given array of ids.
Expand Down Expand Up @@ -3993,14 +3992,20 @@ var Query = /** @class */ (function () {
*/
Query.prototype.first = function () {
var records = this.select();
return this.item(records[0]); // TODO: Delete "as ..." when model type coverage reaches 100%.
if (records.length === 0) {
return null;
}
return this.item(this.hydrate(records[0]));
};
/**
* Returns the last single record of the query chain result.
* Returns the last record of the query chain result.
*/
Query.prototype.last = function () {
var records = this.select();
return this.item(records[records.length - 1]); // TODO: Delete "as ..." when model type coverage reaches 100%.
if (records.length === 0) {
return null;
}
return this.item(this.hydrate(records[records.length - 1]));
};
/**
* Add a and where clause to the query.
Expand Down Expand Up @@ -4091,9 +4096,9 @@ var Query = /** @class */ (function () {
/**
* Add an order to the query.
*/
Query.prototype.orderBy = function (field, direction) {
Query.prototype.orderBy = function (key, direction) {
if (direction === void 0) { direction = 'asc'; }
this.orders.push({ field: field, direction: direction });
this.orders.push({ key: key, direction: direction });
return this;
};
/**
Expand Down Expand Up @@ -4737,7 +4742,7 @@ var Query = /** @class */ (function () {
Query.prototype.buildHooks = function (on) {
var hooks = this.getGlobalHookAsArray(on);
var localHook = this.model[on];
localHook && hooks.push(localHook);
localHook && hooks.push(localHook.bind(this.model));
return hooks;
};
/**
Expand Down
41 changes: 23 additions & 18 deletions dist/vuex-orm.esm.js
Expand Up @@ -669,7 +669,9 @@ function pickBy(object, predicate) {
function orderBy(collection, keys, directions) {
var index = -1;
var result = collection.map(function (value) {
var criteria = keys.map(function (key) { return value[key]; });
var criteria = keys.map(function (key) {
return typeof key === 'function' ? key(value) : value[key];
});
return { criteria: criteria, index: ++index, value: value };
});
return baseSortBy(result, function (object, other) {
Expand Down Expand Up @@ -2660,14 +2662,13 @@ var Model = /** @class */ (function () {
* be filled with its default value defined at model fields definition.
*/
Model.prototype.$fill = function (record) {
var _this = this;
var data = record || {};
var fields = this.$fields();
Object.keys(fields).forEach(function (key) {
for (var key in fields) {
var field = fields[key];
var value = data[key];
_this[key] = field.make(value, data, key);
});
this[key] = field.make(value, data, key);
}
};
/**
* Serialize field values into json.
Expand Down Expand Up @@ -3487,7 +3488,7 @@ var OrderByFilter = /** @class */ (function () {
if (query.orders.length === 0) {
return records;
}
var keys = query.orders.map(function (order) { return order.field; });
var keys = query.orders.map(function (order) { return order.key; });
var directions = query.orders.map(function (order) { return order.direction; });
return Utils.orderBy(records, keys, directions);
};
Expand Down Expand Up @@ -3952,17 +3953,15 @@ var Query = /** @class */ (function () {
return this.get();
};
/**
* Get the record of the given id.
* Find the record by the given id.
*/
Query.prototype.find = function (id) {
id = Array.isArray(id) ? JSON.stringify(id) : id;
var record = this.state.data[id];
var indexId = Array.isArray(id) ? JSON.stringify(id) : id;
var record = this.state.data[indexId];
if (!record) {
return null;
}
var model = this.hydrate(record);
model.$id = String(id);
return this.item(model);
return this.item(this.hydrate(record));
};
/**
* Get the record of the given array of ids.
Expand Down Expand Up @@ -3991,14 +3990,20 @@ var Query = /** @class */ (function () {
*/
Query.prototype.first = function () {
var records = this.select();
return this.item(records[0]); // TODO: Delete "as ..." when model type coverage reaches 100%.
if (records.length === 0) {
return null;
}
return this.item(this.hydrate(records[0]));
};
/**
* Returns the last single record of the query chain result.
* Returns the last record of the query chain result.
*/
Query.prototype.last = function () {
var records = this.select();
return this.item(records[records.length - 1]); // TODO: Delete "as ..." when model type coverage reaches 100%.
if (records.length === 0) {
return null;
}
return this.item(this.hydrate(records[records.length - 1]));
};
/**
* Add a and where clause to the query.
Expand Down Expand Up @@ -4089,9 +4094,9 @@ var Query = /** @class */ (function () {
/**
* Add an order to the query.
*/
Query.prototype.orderBy = function (field, direction) {
Query.prototype.orderBy = function (key, direction) {
if (direction === void 0) { direction = 'asc'; }
this.orders.push({ field: field, direction: direction });
this.orders.push({ key: key, direction: direction });
return this;
};
/**
Expand Down Expand Up @@ -4735,7 +4740,7 @@ var Query = /** @class */ (function () {
Query.prototype.buildHooks = function (on) {
var hooks = this.getGlobalHookAsArray(on);
var localHook = this.model[on];
localHook && hooks.push(localHook);
localHook && hooks.push(localHook.bind(this.model));
return hooks;
};
/**
Expand Down
41 changes: 23 additions & 18 deletions dist/vuex-orm.js
Expand Up @@ -675,7 +675,9 @@
function orderBy(collection, keys, directions) {
var index = -1;
var result = collection.map(function (value) {
var criteria = keys.map(function (key) { return value[key]; });
var criteria = keys.map(function (key) {
return typeof key === 'function' ? key(value) : value[key];
});
return { criteria: criteria, index: ++index, value: value };
});
return baseSortBy(result, function (object, other) {
Expand Down Expand Up @@ -2666,14 +2668,13 @@
* be filled with its default value defined at model fields definition.
*/
Model.prototype.$fill = function (record) {
var _this = this;
var data = record || {};
var fields = this.$fields();
Object.keys(fields).forEach(function (key) {
for (var key in fields) {
var field = fields[key];
var value = data[key];
_this[key] = field.make(value, data, key);
});
this[key] = field.make(value, data, key);
}
};
/**
* Serialize field values into json.
Expand Down Expand Up @@ -3493,7 +3494,7 @@
if (query.orders.length === 0) {
return records;
}
var keys = query.orders.map(function (order) { return order.field; });
var keys = query.orders.map(function (order) { return order.key; });
var directions = query.orders.map(function (order) { return order.direction; });
return Utils.orderBy(records, keys, directions);
};
Expand Down Expand Up @@ -3958,17 +3959,15 @@
return this.get();
};
/**
* Get the record of the given id.
* Find the record by the given id.
*/
Query.prototype.find = function (id) {
id = Array.isArray(id) ? JSON.stringify(id) : id;
var record = this.state.data[id];
var indexId = Array.isArray(id) ? JSON.stringify(id) : id;
var record = this.state.data[indexId];
if (!record) {
return null;
}
var model = this.hydrate(record);
model.$id = String(id);
return this.item(model);
return this.item(this.hydrate(record));
};
/**
* Get the record of the given array of ids.
Expand Down Expand Up @@ -3997,14 +3996,20 @@
*/
Query.prototype.first = function () {
var records = this.select();
return this.item(records[0]); // TODO: Delete "as ..." when model type coverage reaches 100%.
if (records.length === 0) {
return null;
}
return this.item(this.hydrate(records[0]));
};
/**
* Returns the last single record of the query chain result.
* Returns the last record of the query chain result.
*/
Query.prototype.last = function () {
var records = this.select();
return this.item(records[records.length - 1]); // TODO: Delete "as ..." when model type coverage reaches 100%.
if (records.length === 0) {
return null;
}
return this.item(this.hydrate(records[records.length - 1]));
};
/**
* Add a and where clause to the query.
Expand Down Expand Up @@ -4095,9 +4100,9 @@
/**
* Add an order to the query.
*/
Query.prototype.orderBy = function (field, direction) {
Query.prototype.orderBy = function (key, direction) {
if (direction === void 0) { direction = 'asc'; }
this.orders.push({ field: field, direction: direction });
this.orders.push({ key: key, direction: direction });
return this;
};
/**
Expand Down Expand Up @@ -4741,7 +4746,7 @@
Query.prototype.buildHooks = function (on) {
var hooks = this.getGlobalHookAsArray(on);
var localHook = this.model[on];
localHook && hooks.push(localHook);
localHook && hooks.push(localHook.bind(this.model));
return hooks;
};
/**
Expand Down
2 changes: 1 addition & 1 deletion dist/vuex-orm.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@vuex-orm/core",
"version": "0.34.0",
"version": "0.34.1",
"description": "The Vuex plugin to enable Object-Relational Mapping access to the Vuex Store.",
"main": "dist/vuex-orm.common.js",
"module": "dist/vuex-orm.esm.js",
Expand Down

0 comments on commit aabe326

Please sign in to comment.