@@ -44,8 +44,8 @@ export class Model {
4444
4545 /**
4646 * The registry for the model. It contains predefined model schema generated
47- * by the decorators, and gets evaluated and stored at `schema` property
48- * when registering models to the database
47+ * by the property decorators and gets evaluated, and stored, on the `schema`
48+ * property when registering models to the database.
4949 */
5050 protected static registries : ModelRegistries = { }
5151
@@ -64,7 +64,7 @@ export class Model {
6464 }
6565
6666 /**
67- * Build a schema by evaluating fields and registry.
67+ * Build the schema by evaluating fields and registry.
6868 */
6969 static initializeSchema ( ) : void {
7070 this . schemas [ this . entity ] = { }
@@ -90,43 +90,43 @@ export class Model {
9090 }
9191
9292 /**
93- * Clear the list of booted models so they will be re-booted.
93+ * Clear the list of booted models so they can be re-booted.
9494 */
9595 static clearBootedModels ( ) : void {
9696 this . booted = { }
9797 this . schemas = { }
9898 }
9999
100100 /**
101- * Create a new attr attribute instance.
101+ * Create a new Attr attribute instance.
102102 */
103103 static attr ( value : any ) : Attr {
104104 return new Attr ( new this ( ) , value )
105105 }
106106
107107 /**
108- * Create a new string attribute instance.
108+ * Create a new String attribute instance.
109109 */
110110 static string ( value : string | null ) : Str {
111111 return new Str ( new this ( ) , value )
112112 }
113113
114114 /**
115- * Create a new number attribute instance.
115+ * Create a new Number attribute instance.
116116 */
117117 static number ( value : number | null ) : Num {
118118 return new Num ( new this ( ) , value )
119119 }
120120
121121 /**
122- * Create a new boolean attribute instance.
122+ * Create a new Boolean attribute instance.
123123 */
124124 static boolean ( value : boolean | null ) : Bool {
125125 return new Bool ( new this ( ) , value )
126126 }
127127
128128 /**
129- * Create a new has one relation instance.
129+ * Create a new HasOne relation instance.
130130 */
131131 static hasOne (
132132 related : typeof Model ,
@@ -141,7 +141,7 @@ export class Model {
141141 }
142142
143143 /**
144- * Create a new belongs to relation instance.
144+ * Create a new BelongsTo relation instance.
145145 */
146146 static belongsTo (
147147 related : typeof Model ,
@@ -156,7 +156,7 @@ export class Model {
156156 }
157157
158158 /**
159- * Create a new has many relation instance.
159+ * Create a new HasMany relation instance.
160160 */
161161 static hasMany (
162162 related : typeof Model ,
@@ -171,7 +171,7 @@ export class Model {
171171 }
172172
173173 /**
174- * Get the constructor for the model.
174+ * Get the constructor for this model.
175175 */
176176 get $self ( ) : typeof Model {
177177 return this . constructor as typeof Model
@@ -185,14 +185,14 @@ export class Model {
185185 }
186186
187187 /**
188- * Get the entity for the model.
188+ * Get the entity for this model.
189189 */
190190 get $entity ( ) : string {
191191 return this . $self . entity
192192 }
193193
194194 /**
195- * Get the primary key for the model.
195+ * Get the primary key for this model.
196196 */
197197 get $primaryKey ( ) : string {
198198 return this . $self . primaryKey
@@ -208,9 +208,9 @@ export class Model {
208208 }
209209
210210 /**
211- * Create a new instance of the model. This method just provides a convenient
212- * way for us to generate fresh model instances of this current model. It's
213- * particularly useful during the hydration of new objects via the query .
211+ * Create a new instance of this model. This method provides a convenient way
212+ * to re- generate a fresh instance of this model. It's particularly useful
213+ * during hydration through Query operations .
214214 */
215215 $newInstance ( attributes ?: Element , options ?: ModelOptions ) : this {
216216 const model = new this . $self ( attributes , options ) as this
@@ -221,14 +221,14 @@ export class Model {
221221 }
222222
223223 /**
224- * Get model fields for the model.
224+ * Get the model fields for this model.
225225 */
226226 get $fields ( ) : ModelFields {
227227 return this . $self . schemas [ this . $entity ]
228228 }
229229
230230 /**
231- * Bootstrap the model.
231+ * Bootstrap this model.
232232 */
233233 protected $boot ( ) : void {
234234 if ( ! this . $self . booted [ this . $entity ] ) {
@@ -239,15 +239,15 @@ export class Model {
239239 }
240240
241241 /**
242- * Build a schema by evaluating fields and registry.
242+ * Build the schema by evaluating fields and registry.
243243 */
244244 protected $initializeSchema ( ) : void {
245245 this . $self . initializeSchema ( )
246246 }
247247
248248 /**
249- * Fill the model by the given Its default values will fill any
250- * missing field .
249+ * Fill this model by the given attributes. Missing fields will be populated
250+ * by the attributes default value .
251251 */
252252 $fill ( attributes : Element = { } , options : ModelOptions = { } ) : this {
253253 const fillRelation = options . relations ?? true
@@ -267,7 +267,7 @@ export class Model {
267267 }
268268
269269 /**
270- * Fill the model filed .
270+ * Fill the given attribute with a given value specified by the given key .
271271 */
272272 protected $fillField ( key : string , attr : Attribute , value : any ) : void {
273273 if ( value !== undefined ) {
@@ -291,7 +291,7 @@ export class Model {
291291 }
292292
293293 /**
294- * Get the index id for the model or the given record.
294+ * Get the index id of this model or for a given record.
295295 */
296296 $getIndexId ( record ?: Element ) : string {
297297 const target = record ?? this
@@ -300,14 +300,14 @@ export class Model {
300300 }
301301
302302 /**
303- * Get the local key for the model.
303+ * Get the local key for this model.
304304 */
305305 $getLocalKey ( ) : string {
306306 return this . $primaryKey
307307 }
308308
309309 /**
310- * Check if the model has any relations defined in the schema.
310+ * Check if this model has any relations defined by the schema.
311311 */
312312 $hasRelation ( ) : boolean {
313313 let result = false
@@ -353,7 +353,7 @@ export class Model {
353353 }
354354
355355 /**
356- * Serialize given model POJO.
356+ * Serialize this model, or the given model, as POJO.
357357 */
358358 $toJson ( model ?: Model , options : ModelOptions = { } ) : Element {
359359 model = model ?? this
@@ -380,7 +380,7 @@ export class Model {
380380 }
381381
382382 /**
383- * Serialize given value.
383+ * Serialize the given value.
384384 */
385385 protected serializeValue ( v : any ) : any {
386386 if ( v === null ) {
@@ -399,14 +399,14 @@ export class Model {
399399 }
400400
401401 /**
402- * Serialize an array into json .
402+ * Serialize the given array to JSON .
403403 */
404404 protected serializeArray ( a : any [ ] ) : any [ ] {
405405 return a . map ( ( v ) => this . serializeValue ( v ) )
406406 }
407407
408408 /**
409- * Serialize an object into json .
409+ * Serialize the given object to JSON .
410410 */
411411 protected serializeObject ( o : object ) : object {
412412 const obj = { }
@@ -419,7 +419,7 @@ export class Model {
419419 }
420420
421421 /**
422- * Serialize given relation into json .
422+ * Serialize the given relation to JSON .
423423 */
424424 protected serializeRelation ( relation : Item ) : Element | null
425425 protected serializeRelation ( relation : Collection ) : Element [ ]
0 commit comments