Fix eslint database

This commit is contained in:
Alexandre Bodin 2022-09-05 19:44:58 +02:00
parent 22589cf0e1
commit 70b6966458
8 changed files with 22 additions and 16 deletions

View File

@ -34,7 +34,7 @@ const processData = (metadata, data = {}, { withDefaults = false } = {}) => {
const obj = {};
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (types.isScalar(attribute.type)) {
@ -333,7 +333,7 @@ const createEntityManager = (db) => {
async attachRelations(uid, id, data) {
const { attributes } = db.metadata.get(uid);
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
const isValidLink = _.has(attributeName, data) && !_.isNil(data[attributeName]);
@ -487,7 +487,7 @@ const createEntityManager = (db) => {
async updateRelations(uid, id, data) {
const { attributes } = db.metadata.get(uid);
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (attribute.type !== 'relation' || !_.has(attributeName, data)) {
@ -667,7 +667,7 @@ const createEntityManager = (db) => {
async deleteRelations(uid, id) {
const { attributes } = db.metadata.get(uid);
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (attribute.type !== 'relation') {

View File

@ -54,7 +54,7 @@ const createLifecyclesProvider = (db) => {
* @param {Map<any, any>} states
*/
async run(action, uid, properties, states = new Map()) {
for (let i = 0; i < subscribers.length; i++) {
for (let i = 0; i < subscribers.length; i += 1) {
const subscriber = subscribers[i];
if (typeof subscriber === 'function') {
const state = states.get(subscriber) || {};

View File

@ -71,7 +71,7 @@ const applyJoin = (qb, join) => {
inner.on(`${rootTable}.${rootColumn}`, `${alias}.${referencedColumn}`);
if (on) {
for (const key in on) {
for (const key of Object.keys(on)) {
inner.onVal(`${alias}.${key}`, on[key]);
}
}

View File

@ -8,7 +8,7 @@ const { fromRow } = require('./transform');
const getRootLevelPopulate = (meta) => {
const populate = {};
for (const attributeName in meta.attributes) {
for (const attributeName of Object.keys(meta.attributes)) {
const attribute = meta.attributes[attributeName];
if (attribute.type === 'relation') {
populate[attributeName] = true;
@ -72,7 +72,7 @@ const processPopulate = (populate, ctx) => {
}
const finalPopulate = {};
for (const key in populateMap) {
for (const key of Object.keys(populateMap)) {
const attribute = meta.attributes[key];
if (!attribute) {
@ -119,7 +119,7 @@ const applyPopulate = async (results, populate, ctx) => {
return results;
}
for (const key in populate) {
for (const key of Object.keys(populate)) {
const attribute = meta.attributes[key];
const targetMeta = db.metadata.get(attribute.target);
@ -540,7 +540,7 @@ const applyPopulate = async (results, populate, ctx) => {
}, {});
const map = {};
for (const type in idsByType) {
for (const type of Object.keys(idsByType)) {
const ids = idsByType[type];
// type was removed but still in morph relation
@ -604,7 +604,7 @@ const applyPopulate = async (results, populate, ctx) => {
}, {});
const map = {};
for (const type in idsByType) {
for (const type of Object.keys(idsByType)) {
const ids = idsByType[type];
// type was removed but still in morph relation

View File

@ -53,7 +53,7 @@ const toRow = (meta, data = {}) => {
const { attributes } = meta;
for (const key in data) {
for (const key of Object.keys(data)) {
const attribute = attributes[key];
if (!attribute || attribute.columnName === key) {

View File

@ -76,7 +76,7 @@ const processAttributeWhere = (attribute, where, operator = '$eq') => {
const filters = {};
for (const key in where) {
for (const key of Object.keys(where)) {
const value = where[key];
if (!isOperator(key)) {
@ -119,7 +119,7 @@ const processWhere = (where, ctx) => {
const filters = {};
// for each key in where
for (const key in where) {
for (const key of Object.keys(where)) {
const value = where[key];
// if operator $and $or then loop over them

View File

@ -27,7 +27,13 @@ const createQueryBuilder = (uid, db) => {
};
let counter = 0;
const getAlias = () => `t${counter++}`;
const getAlias = () => {
const alias = `t${counter}`;
counter += 1;
return alias;
};
return {
alias: getAlias(),

View File

@ -25,7 +25,7 @@ const createTable = (meta) => {
columns: [],
};
for (const key in meta.attributes) {
for (const key of Object.keys(meta.attributes)) {
const attribute = meta.attributes[key];
if (types.isRelation(attribute.type)) {