From 6d1e47ceafaee4f514f69716339da17ee34d95fe Mon Sep 17 00:00:00 2001 From: Anatoliy Chakkaev Date: Sun, 31 Mar 2013 16:35:26 +0400 Subject: [PATCH] Schemas switching --- Makefile | 8 +++++--- docs/roadmap.md | 2 ++ lib/model.js | 2 +- lib/schema.js | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index fcf7fda2..c10bb085 100644 --- a/Makefile +++ b/Makefile @@ -56,20 +56,22 @@ about-docs: GITBRANCH = $(shell git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') REPO = marcusgreenwood/hatchjs +TARGET = origin FROM = $(GITBRANCH) TO = $(GITBRANCH) pull: - git pull origin $(FROM) + git pull $(TARGET) $(FROM) safe-pull: - git pull origin $(FROM) --no-commit + git pull $(TARGET) $(FROM) --no-commit push: test - git push origin $(TO) + git push $(TARGET) $(TO) feature: git checkout -b feature-$(filter-out $@,$(MAKECMDGOALS)) + git push -u $(TARGET) feature-$(filter-out $@,$(MAKECMDGOALS)) %: @: diff --git a/docs/roadmap.md b/docs/roadmap.md index 43617852..2adb94f0 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -19,6 +19,8 @@ jugglingdb-roadmap - The Future of JugglingDB ## MODEL CORE +* schema switching +* common transaction support * virtual attributes * object presentation modes * mass-assignment protection diff --git a/lib/model.js b/lib/model.js index 9c24e12e..493a1979 100644 --- a/lib/model.js +++ b/lib/model.js @@ -694,7 +694,7 @@ AbstractClass.prototype.isNewRecord = function () { * @private */ AbstractClass.prototype._adapter = function () { - return this.constructor.schema.adapter; + return this.schema.adapter; }; /** diff --git a/lib/schema.js b/lib/schema.js index cf15d8cc..5401c250 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -163,11 +163,12 @@ Schema.prototype.define = function defineClass(className, properties, settings) standartize(properties, settings); // every class can receive hash of data as optional param - var NewClass = function ModelConstructor(data) { + var NewClass = function ModelConstructor(data, schema) { if (!(this instanceof ModelConstructor)) { return new ModelConstructor(data); } AbstractClass.call(this, data); + this.schema = schema || this.constructor.schema; }; hiddenProperty(NewClass, 'schema', schema);