Comparing version 0.0.5 to 0.0.6
@@ -52,5 +52,16 @@ import Sqlite from 'better-sqlite3'; | ||
attr(name: string, value: any): void { | ||
this._attributes[name] = value; | ||
if (this._attributes[name] !== value) { | ||
this._attributes[name] = value; | ||
} | ||
} | ||
getAttr(name: string): any { | ||
return this._attributes[name]; | ||
} | ||
change(name: string, value: any): void { | ||
this.attr(name, value); | ||
this._changed[name] = value; | ||
} | ||
clone(): Model { | ||
@@ -66,6 +77,6 @@ return new (this.constructor as new (options: ModelOpts) => this)(this._options as ModelOpts) | ||
set: (value: any) => { | ||
instance.attr(key, value); | ||
instance.change(key, value); | ||
}, | ||
get: () => { | ||
return instance._attributes[key]; | ||
return instance.getAttr(key); | ||
} | ||
@@ -142,3 +153,2 @@ }); | ||
const { sql, params } = builder.table(this._table).insert(data); | ||
console.log(sql, params); | ||
const { lastInsertRowid } = this.db.prepare(sql).run(...params); | ||
@@ -145,0 +155,0 @@ return this.findById(lastInsertRowid); |
{ | ||
"name": "lite-model", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
61780
1365