Comparing version 2.13.1 to 2.14.0
@@ -293,2 +293,3 @@ var crypto = require("crypto"); | ||
var id = option(modelConfig, 'id', 'id'); | ||
var idType = option(modelConfig, 'idType'); | ||
var table = option(modelConfig, 'table'); | ||
@@ -299,2 +300,3 @@ | ||
id: id, | ||
idType: idType, | ||
db: this, | ||
@@ -301,0 +303,0 @@ foreignKeyFor: foreignKeyFor, |
{ | ||
"name": "sworm", | ||
"version": "2.13.1", | ||
"version": "2.14.0", | ||
"description": "a lightweight write-only ORM for MSSQL, MySQL, PostgreSQL, Oracle, Sqlite 3", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -305,2 +305,3 @@ # SWORM [![npm version](https://img.shields.io/npm/v/sworm.svg)](https://www.npmjs.com/package/sworm) [![npm](https://img.shields.io/npm/dm/sworm.svg)](https://www.npmjs.com/package/sworm) [![Build Status](https://travis-ci.org/featurist/sworm.svg?branch=master)](https://travis-ci.org/featurist/sworm) | ||
* `id` (`'id'`) the name of the identity column. This can be an array of id columns for compound keys, or `false` if there is no id column. | ||
* `idType` (`oracledb.NUMBER`) for `oracledb` the type of the identity column, for e.g. `oracledb.STRING`. | ||
* `foreignKeyFor` a function that returns a foreign key field name for a member (see [Relationships](#relationships)), defaults to: | ||
@@ -307,0 +308,0 @@ |
@@ -76,2 +76,7 @@ if (!process.env.TRAVIS) { | ||
); | ||
}).then(function() { | ||
return createTable("with_string_id", "id", | ||
'create table with_string_id(id varchar(10) primary key, name varchar2(50) NOT NULL)', | ||
true | ||
); | ||
}); | ||
@@ -200,24 +205,54 @@ }, | ||
describe('adding rows with varchar ids', function () { | ||
var db; | ||
beforeEach(function () { | ||
db = sworm.db(config()); | ||
}); | ||
it('can add a row with a varchar id', function () { | ||
}); | ||
}); | ||
describe('options', function () { | ||
it('can pass options to query', function () { | ||
var db = sworm.db(config()); | ||
var person = db.model({table: 'people'}); | ||
var db; | ||
var bob = person({ | ||
name: 'bob' | ||
}); | ||
beforeEach(function () { | ||
db = sworm.db(config()); | ||
}); | ||
return bob.save().then(function () { | ||
return db.query('select * from people', {}, {formatRows: false, outFormat: oracledb.OBJECT}).then(function (rows) { | ||
expect(rows.metaData).to.eql([ | ||
{name: 'ID'}, | ||
{name: 'NAME'}, | ||
{name: 'ADDRESS_ID'}, | ||
{name: 'PHOTO'} | ||
]); | ||
it('can add a row with a varchar id', function () { | ||
var blah = db.model({table: 'with_string_id', idType: oracledb.STRING}); | ||
var b = blah({name: 'asdf', id: 'string'}); | ||
return b.save(); | ||
}); | ||
describe('options', function () { | ||
it('can pass options to query', function () { | ||
var db = sworm.db(config()); | ||
var person = db.model({table: 'people'}); | ||
var bob = person({ | ||
name: 'bob' | ||
}); | ||
return bob.save().then(function () { | ||
return db.query('select * from people', {}, {formatRows: false, outFormat: oracledb.OBJECT}).then(function (rows) { | ||
expect(rows.metaData).to.eql([ | ||
{name: 'ID'}, | ||
{name: 'NAME'}, | ||
{name: 'ADDRESS_ID'}, | ||
{name: 'PHOTO'} | ||
]); | ||
}); | ||
}); | ||
}); | ||
}); | ||
afterEach(function () { | ||
return db.close(); | ||
}); | ||
}); | ||
}); | ||
} |
96622
2297
620