Socket
Socket
Sign inDemoInstall

simple-graphql

Package Overview
Dependencies
Maintainers
1
Versions
300
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-graphql - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

28

dist/build/buildSequelizeModels.js

@@ -26,2 +26,3 @@ "use strict";

}
const extAttributes = {};
lodash_1.default.forOwn(schema.config.fields, (value, key) => {

@@ -61,11 +62,14 @@ var _a;

if (columnOptions) {
dbDefinition[key] = Object.assign({}, columnOptions);
dbDefinition[key].allowNull = value.nullable !== false;
dbDefinition[key] = Object.assign(Object.assign({}, dbDefinition[key]), (((_a = value.metadata) === null || _a === void 0 ? void 0 : _a.column) || {}));
extAttributes[key] = Object.assign(Object.assign(Object.assign({}, columnOptions), { allowNull: value.nullable !== false }), (((_a = value.metadata) === null || _a === void 0 ? void 0 : _a.column) || {}));
}
});
sequelize.define(schema.name, dbDefinition, schema.options.tableOptions);
return sequelize.model(schema.name);
return [
sequelize.define(schema.name, dbDefinition, schema.options.tableOptions),
extAttributes
];
}
function buildModelAssociations(schemas, models) {
// 每次associations的改动, 会触发Model.refreshAttributes操作
// 如果先初始化associations, 再通过通过Model.rawAttributes / refreshAttributes添加其他字段
// 性能大概提升30%
const schemaMap = {};

@@ -114,2 +118,3 @@ schemas.forEach((schema) => (schemaMap[schema.name] = schema));

const result = {};
const extAttributesMap = {};
for (const schema of schemas) {

@@ -119,10 +124,19 @@ if (result[schema.name]) {

}
const model = toSequelizeModel(schema.sequelize || sequelize, schema, context);
const [model, extAttributes] = toSequelizeModel(schema.sequelize || sequelize, schema, context);
Object.assign(model, Object.assign(Object.assign(Object.assign({ sgSchema: schema }, modelStaticsMethod_1.default), schema.config.statics), { getSGContext: () => context }));
Object.assign(model.prototype, Object.assign({ getSGContext: () => context, _fieldType: schema.name }, schema.config.methods));
result[schema.name] = model;
extAttributesMap[schema.name] = extAttributes;
}
buildModelAssociations(schemas, result);
return lodash_1.default.values(result);
return lodash_1.default.values(result).map((model) => {
lodash_1.default.toPairs(extAttributesMap[model.name]).forEach(([key, attribute]) => {
if (model.rawAttributes[key] == null) {
model.rawAttributes[key] = attribute;
}
});
model.refreshAttributes();
return model;
});
};
//# sourceMappingURL=buildSequelizeModels.js.map
{
"name": "simple-graphql",
"version": "5.1.0",
"version": "5.1.1",
"description": "The simple way to generates GraphQL schemas and Sequelize models from your models definition.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc