Socket
Socket
Sign inDemoInstall

tuql

Package Overview
Dependencies
218
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.0

dist/utils/index.js

6

dist/builders/associations.js

@@ -10,2 +10,4 @@ "use strict";

var _utils = require("../utils");
const FK_SUFFIX_REGEX = /(_id|Id)$/;

@@ -72,3 +74,3 @@

options: {
foreignKey: from
foreignKey: (0, _utils.formatFieldName)(from)
}

@@ -81,3 +83,3 @@ });

options: {
foreignKey: from
foreignKey: (0, _utils.formatFieldName)(from)
}

@@ -84,0 +86,0 @@ });

@@ -12,2 +12,4 @@ "use strict";

var _utils = require("../utils");
const transformColumnToType = column => {

@@ -37,5 +39,6 @@ const c = column.toLowerCase();

return columns.reduce((acc, column) => {
acc[column.name] = {
acc[(0, _utils.formatFieldName)(column.name)] = {
type: transformColumnToType(column.type),
primaryKey: column.pk === 1
primaryKey: column.pk === 1,
field: column.name
};

@@ -42,0 +45,0 @@ return acc;

@@ -20,6 +20,8 @@ "use strict";

var _checks = require("../checks");
var _utils = require("../utils");
var _associations = require("./associations");
var _index = require("../utils/index");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -73,6 +75,6 @@

for (let table of tables) {
const [info, infoMeta] = await db.query(`PRAGMA table_info(${table})`);
const foreignKeys = await db.query(`PRAGMA foreign_key_list(${table})`);
const [info, infoMeta] = await db.query(`PRAGMA table_info("${table}")`);
const foreignKeys = await db.query(`PRAGMA foreign_key_list("${table}")`);
if ((0, _checks.isJoinTable)(table, tables)) {
if ((0, _utils.isJoinTable)(table, tables)) {
associations = associations.concat((0, _associations.joinTableAssociations)(table, info, foreignKeys));

@@ -95,3 +97,5 @@ } else {

const key = type === 'belongsTo' ? (0, _pluralize.singular)(to) : to;
models[from][key] = models[from][type](models[to], options);
const fromKey = (0, _utils.findModelKey)(from, models);
const toKey = (0, _utils.findModelKey)(to, models);
models[fromKey][key] = models[fromKey][type](models[toKey], options);
});

@@ -129,4 +133,5 @@ const types = {};

fieldAssociations.hasMany.forEach(associatedModel => {
fields[associatedModel.name] = {
fields[(0, _index.formatFieldName)(associatedModel.name)] = {
type: new _graphql.GraphQLList(types[associatedModel.name]),
args: (0, _graphqlSequelize.defaultListArgs)(model[associatedModel.name]),
resolve: (0, _graphqlSequelize.resolver)(model[associatedModel.name])

@@ -137,3 +142,3 @@ };

const fieldName = (0, _pluralize.singular)(associatedModel.name);
fields[fieldName] = {
fields[(0, _index.formatFieldName)(fieldName)] = {
type: types[associatedModel.name],

@@ -144,4 +149,4 @@ resolve: (0, _graphqlSequelize.resolver)(model[fieldName])

fieldAssociations.belongsToMany.forEach(sides => {
const other = sides.filter(side => side !== model.name);
fields[other] = {
const [other] = sides.filter(side => side !== model.name);
fields[(0, _index.formatFieldName)(other)] = {
type: new _graphql.GraphQLList(types[other]),

@@ -156,3 +161,3 @@ resolve: (0, _graphqlSequelize.resolver)(model[other])

types[key] = type;
acc[key] = {
acc[(0, _index.formatFieldName)(key)] = {
type: new _graphql.GraphQLList(type),

@@ -159,0 +164,0 @@ args: (0, _graphqlSequelize.defaultListArgs)(model),

{
"name": "tuql",
"version": "1.1.0",
"version": "1.2.0",
"description": "",

@@ -22,2 +22,3 @@ "main": "dist/index.js",

"dependencies": {
"camelcase": "^4.1.0",
"command-line-args": "^4.0.7",

@@ -24,0 +25,0 @@ "command-line-usage": "^4.0.1",

@@ -51,3 +51,3 @@ # tuql

**tuql** works one of two ways. It prefers to map your schema based on the your foreign key information in your tables. If foreign keys are not present, **tuql** assumes the following about your schema in order to map relationships:
**tuql** works one of two ways. It prefers to map your schema based on the foreign key information in your tables. If foreign keys are not present, **tuql** assumes the following about your schema in order to map relationships:

@@ -54,0 +54,0 @@ 1. The primary key column is named `id` or `thing_id` or `thingId`, where `thing` is the singular form of the table name. Example: For a table named **posts**, the primary key column should be named `id`, `post_id` or `postId`.

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc