Adopt postgres stuff

This commit is contained in:
Anatoliy Chakkaev 2012-06-02 22:33:29 +04:00
parent 40c9923053
commit 418cc03a27
6 changed files with 7 additions and 4 deletions

View File

@ -44,7 +44,7 @@ MongooseAdapter.prototype.define = function (descr) {
var props = {}; var props = {};
Object.keys(descr.properties).forEach(function (key) { Object.keys(descr.properties).forEach(function (key) {
props[key] = descr.properties[key].type; props[key] = descr.properties[key].type;
if (props[key].name === 'Text') props[key] = String; if (props[key].name === 'Text' || props[key].name === 'JSON') props[key] = String;
}); });
var schema = new mongoose.Schema(props); var schema = new mongoose.Schema(props);
this._models[descr.model.modelName] = mongoose.model(descr.model.modelName, schema); this._models[descr.model.modelName] = mongoose.model(descr.model.modelName, schema);

View File

@ -411,6 +411,7 @@ function datatype(p) {
var dt = ''; var dt = '';
switch (p.type.name) { switch (p.type.name) {
case 'String': case 'String':
case 'JSON':
dt = 'VARCHAR(' + (p.limit || 255) + ')'; dt = 'VARCHAR(' + (p.limit || 255) + ')';
break; break;
case 'Text': case 'Text':

View File

@ -516,6 +516,7 @@ function escape(val) {
function datatype(p) { function datatype(p) {
switch (p.type.name) { switch (p.type.name) {
case 'String': case 'String':
case 'JSON':
return 'varchar'; return 'varchar';
case 'Text': case 'Text':
return 'text'; return 'text';

View File

@ -1,11 +1,12 @@
{ {
"name": "jugglingdb", "name": "jugglingdb",
"description": "ORM for every database: redis, mysql, neo4j, mongodb, postgres, sqlite", "description": "ORM for every database: redis, mysql, neo4j, mongodb, postgres, sqlite",
"version": "0.1.10", "version": "0.1.11",
"author": "Anatoliy Chakkaev <rpm1602@gmail.com>", "author": "Anatoliy Chakkaev <rpm1602@gmail.com>",
"contributors": [ "contributors": [
{ "name": "Anatoliy Chakkaev", "email": "rpm1602@gmail.com" }, { "name": "Anatoliy Chakkaev", "email": "rpm1602@gmail.com" },
{ "name": "Julien Guimont", "email": "julien.guimont@gmail.com" }, { "name": "Julien Guimont", "email": "julien.guimont@gmail.com" },
{ "name": "Joseph Junker", "email": "joseph.jnk@gmail.com" },
{ "name": "Henri Bergius", "email": "henri.bergius@iki.fi" }, { "name": "Henri Bergius", "email": "henri.bergius@iki.fi" },
{ "name": "redvulps", "email": "fabopereira@gmail.com" }, { "name": "redvulps", "email": "fabopereira@gmail.com" },
{ "name": "Felipe Sateler", "email": "fsateler@gmail.com" }, { "name": "Felipe Sateler", "email": "fsateler@gmail.com" },

View File

@ -3,7 +3,7 @@ Schema = juggling.Schema
Text = Schema.Text Text = Schema.Text
DBNAME = process.env.DBNAME || 'myapp_test' #this db must already exist and will be destroyed DBNAME = process.env.DBNAME || 'myapp_test' #this db must already exist and will be destroyed
DBUSER = process.env.DBUSER || 'root' DBUSER = process.env.DBUSER || 'postgres'
DBPASS = '' DBPASS = ''
DBENGINE = process.env.DBENGINE || 'postgres' DBENGINE = process.env.DBENGINE || 'postgres'

View File

@ -3,7 +3,7 @@ Schema = juggling.Schema
Text = Schema.Text Text = Schema.Text
DBNAME = process.env.DBNAME || 'myapp_test' #this db must already exist and will be destroyed DBNAME = process.env.DBNAME || 'myapp_test' #this db must already exist and will be destroyed
DBUSER = process.env.DBUSER || 'root' DBUSER = process.env.DBUSER || 'postgres'
DBPASS = '' DBPASS = ''
DBENGINE = process.env.DBENGINE || 'postgres' DBENGINE = process.env.DBENGINE || 'postgres'