breeze-sequelize
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -23,2 +23,3 @@ "use strict"; | ||
utils_1.log("Connected to database: " + dbConfig.dbName); | ||
sequelize.close(); | ||
return "success"; | ||
@@ -42,2 +43,3 @@ } | ||
utils_1.log("Database created: " + dbConfig.dbName); | ||
sequelize.close(); | ||
} | ||
@@ -44,0 +46,0 @@ catch (err) { |
@@ -95,6 +95,7 @@ "use strict"; | ||
} | ||
const pluralName = sequelize_1.Utils.pluralize(model.name); | ||
const config = { | ||
shortName: model.name, | ||
namespace: namespace, | ||
defaultResourceName: model.name, | ||
defaultResourceName: pluralName, | ||
}; | ||
@@ -111,3 +112,3 @@ const et = new breeze_client_1.EntityType(config); | ||
const dp = new breeze_client_1.DataProperty({ | ||
nameOnServer: attr.field, | ||
nameOnServer: attrName, | ||
isNullable: attr.allowNull, | ||
@@ -136,7 +137,7 @@ isPartOfKey: attr.primaryKey, | ||
let propName; | ||
if (attr.field.toLowerCase().endsWith('id')) { | ||
propName = attr.field.substring(0, attr.field.length - 2); | ||
if (attrName.toLowerCase().endsWith('id')) { | ||
propName = attrName.substring(0, attrName.length - 2); | ||
} | ||
else { | ||
propName = refName; | ||
propName = this.matchCase(refName, attrName); | ||
// if there's an existing property, add fk name to property name to make it unique | ||
@@ -148,5 +149,5 @@ if (et.getNavigationProperty(propName)) { | ||
const np = new breeze_client_1.NavigationProperty({ | ||
associationName: (model.name + '_' + propName + '_' + attr.field).toLocaleLowerCase(), | ||
associationName: (model.name + '_' + propName + '_' + attrName).toLocaleLowerCase(), | ||
entityTypeName: refName, | ||
foreignKeyNamesOnServer: [attr.field], | ||
foreignKeyNamesOnServer: [attrName], | ||
isScalar: true, | ||
@@ -172,3 +173,3 @@ nameOnServer: propName | ||
// inverseName is e.g. "Orders" | ||
let inverseName = this.matchCase(this.pluralize(entityType.shortName), nav.nameOnServer); | ||
let inverseName = this.matchCase(sequelize_1.Utils.pluralize(entityType.shortName), nav.nameOnServer); | ||
// navType is e.g. Customer | ||
@@ -195,11 +196,2 @@ const navType = ms.getAsEntityType(nav.entityTypeName); | ||
} | ||
/** naive pluralizer */ | ||
pluralize(s) { | ||
if (s.endsWith('y')) { | ||
return s.substring(0, s.length - 1) + "ies"; | ||
} | ||
else { | ||
return s + "s"; | ||
} | ||
} | ||
/** Make the first char of s match the case of the first char of the target string */ | ||
@@ -206,0 +198,0 @@ matchCase(s, target) { |
{ | ||
"name": "breeze-sequelize", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Breeze Sequelize server implementation", | ||
@@ -48,5 +48,5 @@ "keywords": [ | ||
"build": "tsc && npm pack && npm run install-to-demo && npm run install-to-unit", | ||
"install-to-demo": "cd ../test/BreezeExpressDemo && npm install ../../src/breeze-sequelize-0.6.0.tgz", | ||
"install-to-unit": "cd ../test/unit && npm install ../../src/breeze-sequelize-0.6.0.tgz", | ||
"install-to-core": "cd ../../../northwind-demo/NorthwindCore/NorthwindSequelize && npm install ../../../breeze.server.node/breeze-sequelize/src/breeze-sequelize-0.6.0.tgz", | ||
"install-to-demo": "cd ../test/BreezeExpressDemo && npm install ../../src/breeze-sequelize-0.6.1.tgz", | ||
"install-to-unit": "cd ../test/unit && npm install ../../src/breeze-sequelize-0.6.1.tgz", | ||
"install-to-core": "cd ../../../northwind-demo/NorthwindCore/NorthwindSequelize && npm install ../../../breeze.server.node/breeze-sequelize/src/breeze-sequelize-0.6.1.tgz", | ||
"clean": "rimraf *.js && rimraf *.map && rimraf types" | ||
@@ -53,0 +53,0 @@ }, |
@@ -28,3 +28,3 @@ # breeze-sequelize | ||
an example of using Breeze-Sequelize in a web application. It is part of the [northwind-demo](https://github.com/Breeze/northwind-demo) | ||
that shows how to use Breeze to manage data from the database to a single-page web application. | ||
that shows how to use Breeze to manage data end-to-end, from the database to a single-page web application. | ||
@@ -359,8 +359,8 @@ "use strict"; | ||
_populateExpand(result, sqResult, expandProps) { | ||
if (expandProps == null || expandProps.length === 0) { | ||
return; | ||
} | ||
if (result.$ref) { | ||
result = this._refMap[result.$ref]; | ||
} | ||
if (expandProps == null || expandProps.length === 0) { | ||
return; | ||
} | ||
// now blow out all of the expands | ||
@@ -367,0 +367,0 @@ // each expand path consist of an array of expand props. |
@@ -17,4 +17,2 @@ import { MetadataStore } from "breeze-client"; | ||
private addInverseNavigations; | ||
/** naive pluralizer */ | ||
private pluralize; | ||
/** Make the first char of s match the case of the first char of the target string */ | ||
@@ -21,0 +19,0 @@ private matchCase; |
110035
2323