1- import { Store } from 'vuex'
21import { isNullish , isArray , assert } from '../support/Utils'
32import { Element , Item , Collection } from '../data/Data'
43import { Query } from '../query/Query'
@@ -14,6 +13,7 @@ import { HasOne } from './attributes/relations/HasOne'
1413import { BelongsTo } from './attributes/relations/BelongsTo'
1514import { HasMany } from './attributes/relations/HasMany'
1615import { HasManyBy } from './attributes/relations/HasManyBy'
16+ import { Database } from '@/database/Database'
1717
1818export type ModelFields = Record < string , Attribute >
1919export type ModelSchemas = Record < string , ModelFields >
@@ -55,10 +55,10 @@ export class Model {
5555 protected static booted : Record < string , boolean > = { }
5656
5757 /**
58- * The store instance.
58+ * The database instance.
5959 */
6060 @NonEnumerable
61- protected _store ! : Store < any >
61+ protected _database ! : Database
6262
6363 /**
6464 * Create a new model instance.
@@ -243,23 +243,23 @@ export class Model {
243243 }
244244
245245 /**
246- * Get the store instance.
246+ * Get the database instance.
247247 */
248- $store ( ) : Store < any > {
249- assert ( this . _store !== undefined , [
248+ $database ( ) : Database {
249+ assert ( this . _database !== undefined , [
250250 'A Vuex Store instance is not injected into the model instance.' ,
251251 'You might be trying to instantiate the model directly. Please use' ,
252252 '`repository.make` method to create a new model instance.'
253253 ] )
254254
255- return this . _store
255+ return this . _database
256256 }
257257
258258 /**
259- * Set the store instance.
259+ * Set the database instance.
260260 */
261- $setStore ( store : Store < any > ) : this {
262- this . _store = store
261+ $setDatabase ( database : Database ) : this {
262+ this . _database = database
263263
264264 return this
265265 }
@@ -294,7 +294,7 @@ export class Model {
294294 const self = this . $self ( )
295295 const model = new self ( attributes , options ) as this
296296
297- model . $setStore ( this . $store ( ) )
297+ model . $setDatabase ( this . $database ( ) )
298298
299299 return model
300300 }
@@ -303,7 +303,7 @@ export class Model {
303303 * Create a new query instance.
304304 */
305305 $query ( ) : Query < this> {
306- return new Query ( this . $store ( ) , this )
306+ return new Query ( this . $database ( ) , this )
307307 }
308308
309309 /**
0 commit comments