Comparing version 1.4.0 to 1.4.1
@@ -1,4 +0,10 @@ | ||
1.4.0 / 2020-06-24 | ||
1.4.1 / 2021-06-25 | ||
================== | ||
* refactor: simplify legacy timestamps support (#120) | ||
* refactor: do not subclass Bone unless asked specifically (#120) | ||
1.4.0 / 2021-06-24 | ||
================== | ||
* feat: `realm.raw('SELECT ...')` and `Model.raw('SELECT ...')` (#94) | ||
@@ -19,3 +25,3 @@ * feat: support multiple order rules in one single string or one-dimensional array (#92) | ||
1.3.0 / 2020-03-01 | ||
1.3.0 / 2021-03-01 | ||
================== | ||
@@ -22,0 +28,0 @@ |
16
index.js
@@ -52,8 +52,2 @@ 'use strict'; | ||
const LEGACY_TIMESTAMP_MAP = { | ||
gmtCreate: 'createdAt', | ||
gmtModified: 'updatedAt', | ||
gmtDeleted: 'deletedAt', | ||
}; | ||
function initAttributes(model, columns) { | ||
@@ -65,3 +59,3 @@ const attributes = {}; | ||
const name = columnName == '_id' ? columnName : camelCase(columnName); | ||
attributes[ LEGACY_TIMESTAMP_MAP[name] || name ] = { | ||
attributes[name] = { | ||
...columnInfo, | ||
@@ -93,4 +87,4 @@ type: model.driver.DataTypes.findType(dataType), | ||
function createSpine(opts) { | ||
if (opts.Bone) return opts.Bone; | ||
if (opts.sequelize) return sequelize(Bone); | ||
if (opts.subclass !== true) return Bone; | ||
return class Spine extends Bone {}; | ||
@@ -109,4 +103,3 @@ } | ||
// test/integration/suite/migrations.js currently depends on this behavior | ||
const driver = opts.driver || new (findDriver(dialect))({ | ||
const driver = new (findDriver(dialect))({ | ||
client, | ||
@@ -250,4 +243,3 @@ database, | ||
const connect = async function connect(opts = {}) { | ||
opts = { Bone, ...opts }; | ||
if (opts.Bone.driver) throw new Error('connected already'); | ||
if (Bone.driver) throw new Error('connected already'); | ||
const realm = new Realm(opts); | ||
@@ -254,0 +246,0 @@ return await realm.connect(); |
@@ -19,8 +19,7 @@ 'use strict'; | ||
const LEGACY_TIMESTAMP_MAP = { | ||
createdAt: 'gmtCreate', | ||
updatedAt: 'gmtModified', | ||
deletedAt: 'gmtDeleted', | ||
gmtCreate: 'createdAt', | ||
gmtModified: 'updatedAt', | ||
gmtDeleted: 'deletedAt', | ||
}; | ||
function looseReadonly(props) { | ||
@@ -797,4 +796,4 @@ return Object.keys(props).reduce((result, name) => { | ||
* @static | ||
* @param {object} values | ||
* @param {object} options | ||
* @param {object} values | ||
* @param {object} options | ||
* @returns number of affectedRows. | ||
@@ -1387,2 +1386,10 @@ */ | ||
for (const name in LEGACY_TIMESTAMP_MAP) { | ||
const newName = LEGACY_TIMESTAMP_MAP[name]; | ||
if (attributes.hasOwnProperty(name) && !attributes.hasOwnProperty(newName)) { | ||
attributes[newName] = attributes[name]; | ||
delete attributes[name]; | ||
} | ||
} | ||
const timestamps = {}; | ||
@@ -1394,3 +1401,2 @@ for (const name of [ 'createdAt', 'updatedAt', 'deletedAt' ]) { | ||
} | ||
if (attributes.hasOwnProperty(LEGACY_TIMESTAMP_MAP[name])) timestamps[name] = LEGACY_TIMESTAMP_MAP[name]; | ||
} | ||
@@ -1397,0 +1403,0 @@ |
{ | ||
"name": "leoric", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "JavaScript Object-relational mapping alchemy", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
243559
7102