Model
API > [PersistentModel Module] > Model
Class
A model is a schema of a given type represented in TypeScript or JavaScript. This is where a lot of the magic happens in @besync/GraphStore, as behind the scenes every field is represented as some sort of extended Observable -- a MobX observable with some extra batteries included.
Hierarchy
Model
↳ Submodel
Implements
Constructors
Properties
Methods
Constructors
any
, graphStore?: IGraphStore): Model
⊕ new Model(defaults: Defined in PersistentModel.ts:43
Constructor
Parameters:
Param | Type | Description |
---|---|---|
defaults | any | key value dictionary to populate the initial model |
graphStore | IGraphStore | - |
Returns: Model
Properties
_isDirty
● _isDirty: boolean
Defined in PersistentModel.ts:32
exists
● exists: boolean
= true
Defined in PersistentModel.ts:27
loading
● loading: boolean
= false
Defined in PersistentModel.ts:26
status
● status: Status
Defined in PersistentModel.ts:28
Methods
addObserver
► addObserver(): void
Implementation of IEnhancedObservableDelegate.addObserver
Defined in PersistentModel.ts:106
IEnhancedObservableDelegate.addObserver
Used internally by @besync/GraphStore to indicate when the first new observer is watching this collection
Returns: void
delete
► delete(): void
Defined in PersistentModel.ts:96
Deletes this document from the store
Returns: void
keys
► keys(): string
[]
Defined in PersistentModel.ts:173
Get the keys of this model, including both owned properties and those managed by @besync/GraphStore
Returns: string
[]
List of keys as a string array
releaseObserver
► releaseObserver(): void
Implementation of IEnhancedObservableDelegate.releaseObserver
Defined in PersistentModel.ts:117
IEnhancedObservableDelegate.addObserver
Used internally by @besync/GraphStore to indicate when no more observers are watching this collection
Returns: void
toString
► toString(): string
Defined in PersistentModel.ts:183
Gets a string representation of this model in JSON format, useful for debugging purposes
Returns: string
string representation of this model in JSON format
«Static» getCollection
► getCollection(keys: any
, path: string
): any
[]
Defined in PersistentModel.ts:224
Class method to get an observable collection of documents from the default persistent store param:: path A string representing the database access path to the location of the collection
Parameters:
Param | Type | Description |
---|---|---|
keys | any | A key:value dictionary representing the subset of primary keys to query on |
path | string | - |
Returns: any
[]
An instance of this model that can be observed over time to represent the selected document
«Static» getDocument
► getDocument(keys: any
, path: string
): any
Defined in PersistentModel.ts:203
Class method to get an observable document from the default persistent store param:: path A string representing the database access path to the location of the document
Parameters:
Param | Type | Description |
---|---|---|
keys | any | A key:value dictionary representing the primary keys to query on |
path | string | - |
Returns: any
An instance of this model that can be observed over time to represent the selected document
«Static» setDefaultStore
► setDefaultStore(graphStore: IGraphStore): void
Defined in PersistentModel.ts:192
Class method to set the default persistent store for all instances of this model type
Parameters:
Param | Type | Description |
---|---|---|
graphStore | IGraphStore | the default persistent store |
Returns: void