diff --git a/src/classes/Instance.ts b/src/classes/Instance.ts index 5e5f505..15d6c6c 100644 --- a/src/classes/Instance.ts +++ b/src/classes/Instance.ts @@ -20,11 +20,11 @@ export class Instance { public delete() { const db = FileUtils.readJson("./database/db.json") - const filtered_table = db[this._schema.name] + const filteredTable = db[this._schema.name] .filter(row => row._id !== this._fields._id) FileUtils.writeJson("./database/db.json", { ...db, - [this._schema.name]: filtered_table + [this._schema.name]: filteredTable }) } @@ -32,14 +32,14 @@ export class Instance { const db = FileUtils.readJson("./database/db.json") if (!this._options.isNew) { - const filtered_table = db[this._schema.name] + const filteredTable = db[this._schema.name] .filter(row => row._id !== this._fields._id) - new ColumnsUtils(this._schema.columns, filtered_table, this._fields) - filtered_table.push(this._fields) + new ColumnsUtils(this._schema.columns, filteredTable, this._fields) + filteredTable.push(this._fields) FileUtils.writeJson("./database/db.json", { ...db, - [this._schema.name]: filtered_table + [this._schema.name]: filteredTable } ) } else { diff --git a/src/classes/Model.ts b/src/classes/Model.ts index 38b5b6b..1fc7fbc 100644 --- a/src/classes/Model.ts +++ b/src/classes/Model.ts @@ -29,11 +29,11 @@ export class Model { const table = db[this.schema.name] ?? [] const keys = Object.keys(args) as unknown as Array - const filtered_table = table.filter(row => + const filteredTable = table.filter(row => keys.every(key => ObjectUtils.nestedCheck(row, key, args[key]))) - return filtered_table.map(row => new Instance(this.schema, row, { + return filteredTable.map(row => new Instance(this.schema, row, { isNew: false })) } diff --git a/src/classes/Schema.ts b/src/classes/Schema.ts index a6c2121..9985ce5 100644 --- a/src/classes/Schema.ts +++ b/src/classes/Schema.ts @@ -19,11 +19,11 @@ export class Schema { public static initializeSchema(args: T) { const instance = new args() - const keys = Object.keys(instance).filter(key => key !== "_table_name" && key !== "_id") + const keys = Object.keys(instance).filter(key => key !== "_tableName" && key !== "_id") const options = keys.map(key => ({ name: key, options: getFormat(instance, key) })) - return new Schema(instance["_table_name"], options) + return new Schema(instance["_tableName"], options) } } diff --git a/src/decorators/TinyTable.ts b/src/decorators/TinyTable.ts index c14e40b..15ce4f4 100644 --- a/src/decorators/TinyTable.ts +++ b/src/decorators/TinyTable.ts @@ -5,7 +5,7 @@ export function TinyTable(name: string) { // deno-lint-ignore no-explicit-any return function }>(Constructor: T) { return class extends Constructor { - _table_name: string = name + _tableName: string = name _id!: string // deno-lint-ignore no-explicit-any diff --git a/src/interfaces/Document.ts b/src/interfaces/Document.ts index 9ffdaf4..dd07af3 100644 --- a/src/interfaces/Document.ts +++ b/src/interfaces/Document.ts @@ -1,4 +1,4 @@ export interface Document { _id: string; - _table_name: string; + _tableName: string; }