sequelize-temporal
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -14,4 +14,4 @@ var _ = require('lodash'); | ||
//var historyName = model.name + 'History'; | ||
var historyName = model.getTableName() + 'History'; | ||
var historyName = model.name + 'History'; | ||
//var historyName = model.getTableName() + 'History'; | ||
//var historyName = model.options.name.singular + 'History'; | ||
@@ -18,0 +18,0 @@ |
{ | ||
"name": "sequelize-temporal", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Temporal tables for Sequelize", | ||
@@ -38,4 +38,5 @@ "main": "index.js", | ||
"mocha": "^2.3.4", | ||
"sequelize": "^3.14.2" | ||
"sequelize": "^3.14.2", | ||
"sqlite3": "^3.1.1" | ||
} | ||
} |
@@ -5,3 +5,3 @@ Temporal tables for Sequelize | ||
[![Build Status](https://travis-ci.org/bonaval/sequelize-temporal.svg?branch=master)](https://travis-ci.org/bonaval/sequelize-temporal) [![Dependency Status](https://david-dm.org/bonaval/sequelize-temporal.svg)](https://david-dm.org/bonaval/sequelize-temporal) [![NPM version](https://img.shields.io/npm/v/npm.svg)](https://img.shields.io/npm/v/npm.svg) | ||
[![Build Status](https://travis-ci.org/bonaval/sequelize-temporal.svg?branch=master)](https://travis-ci.org/bonaval/sequelize-temporal) [![Dependency Status](https://david-dm.org/bonaval/sequelize-temporal.svg)](https://david-dm.org/bonaval/sequelize-temporal) [![NPM version](https://img.shields.io/npm/v/sequelize-temporal.svg)](https://www.npmjs.com/package/sequelize-temporal) | ||
@@ -20,6 +20,6 @@ | ||
The normal singular/plural naming scheme in Sequelize is used | ||
The normal singular/plural naming scheme in Sequelize is used: | ||
- table name: `tableName() + Histories` | ||
- model name: `tableName() + History` | ||
- model name: `modelName + History` | ||
- table name: `modelName + Histories` | ||
@@ -94,2 +94,6 @@ Installation | ||
### Notes | ||
If you only use Postgres, you might want to have a look at the [Temporal Table](https://github.com/arkhipov/temporal_tables) extension. | ||
License | ||
@@ -96,0 +100,0 @@ ------- |
@@ -10,3 +10,3 @@ var Temporal = require('../'); | ||
describe('Read-only API', function(){ | ||
var sequelize, User, UsersHistory; | ||
var sequelize, User, UserHistory; | ||
@@ -22,3 +22,3 @@ function freshDB(){ | ||
}), sequelize); | ||
UsersHistory = sequelize.models.UsersHistory; | ||
UserHistory = sequelize.models.UserHistory; | ||
return sequelize.sync({ force: true }); | ||
@@ -41,10 +41,11 @@ } | ||
return User.create() | ||
.then(assertCount(UsersHistory,0)) | ||
.then(assertCount(UserHistory,0)) | ||
.then(function(user){ | ||
user.name = "foo"; | ||
return user.save(); | ||
}).then(assertCount(UsersHistory,1)) | ||
}).then(assertCount(UserHistory,1)) | ||
.then(function(user){ | ||
return user.destroy(); | ||
}).then(assertCount(UsersHistory,2)) | ||
}).then(assertCount(UserHistory,2)) | ||
.catchThrow(); | ||
}); | ||
@@ -59,11 +60,11 @@ }); | ||
return User.create(opts) | ||
.then(assertCount(UsersHistory,0, opts)) | ||
.then(assertCount(UserHistory,0, opts)) | ||
.then(function(user){ | ||
user.name = "foo"; | ||
return user.save(opts); | ||
}).then(assertCount(UsersHistory,1, opts)) | ||
}).then(assertCount(UserHistory,1, opts)) | ||
.then(function(){ | ||
t.rollback(); | ||
}); | ||
}).then(assertCount(UsersHistory,0)); | ||
}).then(assertCount(UserHistory,0)); | ||
}); | ||
@@ -78,6 +79,6 @@ }); | ||
{name: "foo2"}, | ||
]).then(assertCount(UsersHistory,0)) | ||
]).then(assertCount(UserHistory,0)) | ||
.then(function(){ | ||
return User.update({ name: 'updated-foo' }, {where: {}}); | ||
}).then(assertCount(UsersHistory,2)) | ||
}).then(assertCount(UserHistory,2)) | ||
}); | ||
@@ -90,10 +91,10 @@ it('should revert under transactions' , function(){ | ||
{name: "foo2"}, | ||
], opts).then(assertCount(UsersHistory,0,opts)) | ||
], opts).then(assertCount(UserHistory,0,opts)) | ||
.then(function(){ | ||
return User.update({ name: 'updated-foo' }, {where: {}, transaction: t}); | ||
}).then(assertCount(UsersHistory,2, opts)) | ||
}).then(assertCount(UserHistory,2, opts)) | ||
.then(function(){ | ||
t.rollback(); | ||
}); | ||
}).then(assertCount(UsersHistory,0)); | ||
}).then(assertCount(UserHistory,0)); | ||
}); | ||
@@ -109,3 +110,3 @@ | ||
{name: "foo2"}, | ||
]).then(assertCount(UsersHistory,0)) | ||
]).then(assertCount(UserHistory,0)) | ||
.then(function(){ | ||
@@ -116,3 +117,3 @@ return User.destroy({ | ||
}); | ||
}).then(assertCount(UsersHistory,2)) | ||
}).then(assertCount(UserHistory,2)) | ||
}); | ||
@@ -125,3 +126,3 @@ it('should revert under transactions' , function(){ | ||
{name: "foo2"}, | ||
], opts).then(assertCount(UsersHistory,0,opts)) | ||
], opts).then(assertCount(UserHistory,0,opts)) | ||
.then(function(){ | ||
@@ -133,7 +134,7 @@ return User.destroy({ | ||
}); | ||
}).then(assertCount(UsersHistory,2, opts)) | ||
}).then(assertCount(UserHistory,2, opts)) | ||
.then(function(){ | ||
t.rollback(); | ||
}); | ||
}).then(assertCount(UsersHistory,0)); | ||
}).then(assertCount(UserHistory,0)); | ||
}); | ||
@@ -146,3 +147,3 @@ | ||
it('should forbid updates' , function(){ | ||
var userUpdate = UsersHistory.create().then(function(uh){ | ||
var userUpdate = UserHistory.create().then(function(uh){ | ||
uh.update({name: 'bla'}); | ||
@@ -153,3 +154,3 @@ }); | ||
it('should forbid deletes' , function(){ | ||
var userUpdate = UsersHistory.create().then(function(uh){ | ||
var userUpdate = UserHistory.create().then(function(uh){ | ||
uh.destroy(); | ||
@@ -156,0 +157,0 @@ }); |
Sorry, the diff of this file is not supported yet
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
13593
223
120
5