Skip to content

Commit

Permalink
Updated readme and changelog, v0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
saschagehlich committed Jan 7, 2014
1 parent 56b639d commit bfe621c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
0.0.6 (Jan 7 2014)
==================

* Models now take a model as the constructor parameter instead of the sequelize model. All helpers will be called on that map.
* Added error message for missing association models
* Added a `modelMatch` option (can be a string, a regular expression or a function)

0.0.5 (Jan 6 2014)
==================

Expand Down
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Since `sequenice` is just a model wrapper for `sequelize`, you will have to init
var Sequenice = require("sequenice")
, new Sequenice(database, {
modelsDirectory: __dirname + "/models", // The path to your models folder
modelsMatch: "**/*.js", // A string, regex or filter function for selecting the correct files
modelsAttacher: global, // The object you want to attach your models to
getterPrefix: "get", // See "Defining models"
setterPrefix: "set", // See "Defining models"
Expand All @@ -46,41 +47,39 @@ Inside the constructor you have access to a couple of helpers which will define
Here's an example:

```js
function Product(s) {
// `s` points to the Sequelize module

function Product(map) {
// Field definitions
this.field("name", s.STRING);
this.field("isPublished", s.BOOLEAN, { defaultValue: false });
map.field("name", s.STRING);
map.field("isPublished", s.BOOLEAN, { defaultValue: false });

// Associations
// hasOne, belongsTo, hasMany
// Pass the associated model name as a string.
this.hasMany("Variants");
this.belongsTo("Category");
map.hasMany("Variants");
map.belongsTo("Category");

// Hooks
// beforeValidate, beforeCreate, ...
// Pass the method name as a string.
this.beforeCreate("publish");
map.beforeCreate("publish");

// Getters / Setters
// Define getterMethods and setterMethods. Pass the variable name
// as a string.
// If your getterPrefix is "get" and the variable name is "price",
// sequenice will try to call the "getPrice" method of your class.
this.get("price");
this.set("price");
map.get("price");
map.set("price");

// Validations
// Pass the validation method name as a string.
this.validates("cheap");
map.validates("cheap");

// Indices
this.index(["name", "isPublished"], { indexName: "NameIsPublished" });
map.index(["name", "isPublished"], { indexName: "NameIsPublished" });

// Model options
this.options({
map.options({
timestamps: false
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sequenice",
"version": "0.0.5",
"version": "0.0.6",
"description": "A nice model wrapper for `sequelize`",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit bfe621c

Please sign in to comment.