@@ -218,7 +218,7 @@ BaseModel.prototype.init = function (obj, options) {
218218
219219 const schema = this . schema ;
220220
221- for ( const [ path , options ] of Object . entries ( schema . attributes ) . concat ( Object . entries ( schema . relationships ) ) ) {
221+ for ( const [ path , property ] of Object . entries ( schema . attributes ) . concat ( Object . entries ( schema . relationships ) ) ) {
222222 Object . defineProperty ( this , path , {
223223 enumerable : true ,
224224 configurable : true ,
@@ -230,10 +230,10 @@ BaseModel.prototype.init = function (obj, options) {
230230 }
231231 } ) ;
232232
233- if ( options ?. default !== undefined ) {
234- const defaultValue = typeof options . default === 'function'
235- ? options . default ( )
236- : options . default ;
233+ if ( property ?. default !== undefined ) {
234+ const defaultValue = typeof property . default === 'function'
235+ ? property . default ( )
236+ : property . default ;
237237 this . set ( path , defaultValue , { skipMarkModified : true } ) ;
238238 }
239239 }
@@ -283,7 +283,7 @@ BaseModel.prototype.delete = async function () {
283283 `/${ this . type } /${ this . id } ` ,
284284 this . toJsonApi ( ) ,
285285 ) ;
286- }
286+ } ;
287287
288288BaseModel . prototype . get = function ( path , options ) {
289289 const schema = this . schema ;
@@ -339,7 +339,7 @@ BaseModel.prototype.save = async function () {
339339 }
340340
341341 return this ;
342- }
342+ } ;
343343
344344BaseModel . prototype . set = function ( path , value , options ) {
345345 const schema = this . schema ;
@@ -383,22 +383,22 @@ BaseModel.prototype.toJsonApi = function () {
383383 relationships : { } ,
384384 } ;
385385
386- for ( const [ attribute , options ] of Object . entries ( this . schema . attributes ) ) {
386+ for ( const [ attribute , property ] of Object . entries ( this . schema . attributes ) ) {
387387 if ( ! this . isNew && ! this . isModified ( attribute ) ) continue ;
388388
389389 let value = this . get ( attribute ) ;
390- if ( options ?. transform ) {
391- value = options . transform ( value ) ;
390+ if ( property ?. transform ) {
391+ value = property . transform ( value ) ;
392392 } else {
393- if ( options ?. type === Date && value instanceof Date ) {
393+ if ( property ?. type === Date && value instanceof Date ) {
394394 value = value . toISOString ( ) ;
395395 }
396396 }
397397
398398 data . attributes ! [ attribute ] = value ;
399399 }
400400
401- for ( const [ relationship , options ] of Object . entries ( this . schema . relationships ) ) {
401+ for ( const [ relationship , property ] of Object . entries ( this . schema . relationships ) ) {
402402 if ( ! this . isNew && ! this . isModified ( relationship ) ) continue ;
403403
404404 const value = this . get ( relationship ) as ModelInstance < Record < string , any > > | ModelInstance < Record < string , any > > [ ] | null ;
0 commit comments