Skip to content

Commit

Permalink
Linting update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarasikee committed Aug 7, 2022
1 parent 2f070e5 commit 0e8bb33
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/classes/Instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ export class Instance<T extends { _id: string }> {

public delete() {
const db = FileUtils.readJson<T>("./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
})
}

public save() {
const db = FileUtils.readJson<T>("./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 {
Expand Down
4 changes: 2 additions & 2 deletions src/classes/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export class Model<T extends { _id: string }> {
const table = db[this.schema.name] ?? []
const keys = Object.keys(args) as unknown as Array<keyof T>

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<T>(this.schema, row, {
return filteredTable.map(row => new Instance<T>(this.schema, row, {
isNew: false
}))
}
Expand Down
4 changes: 2 additions & 2 deletions src/classes/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export class Schema {
public static initializeSchema<T extends { new(...args: any[]): any }>(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)
}
}
2 changes: 1 addition & 1 deletion src/decorators/TinyTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function TinyTable(name: string) {
// deno-lint-ignore no-explicit-any
return function <T extends { new(...args: any[]): Record<string, any> }>(Constructor: T) {
return class extends Constructor {
_table_name: string = name
_tableName: string = name
_id!: string

// deno-lint-ignore no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/Document.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface Document {
_id: string;
_table_name: string;
_tableName: string;
}

0 comments on commit 0e8bb33

Please sign in to comment.