Store Class
Base class for application store. service:store should point to instance of that class.
Item Index
Methods
Methods
_dbInit
()
private
Update all databases in accordance with actual schemas.
_getModelName
-
methodName
-
methodArguments
Detect model name by method name and arguments.
Returns:
adapterFor
-
modelName
-
[useOnlineStore]
Returns an instance of the adapter for a given type.
Parameters:
Returns:
Adapter
batchSelect
-
queries
-
[useOnlineStore]
A method to get array of models with batch request.
Parameters:
-
queries
QueryArray of Flexberry Query objects.
-
[useOnlineStore]
Boolean optionalAllow to explicitly specify online or offline store using independently of global online status.
Returns:
A promise that fulfilled with an array of query responses.
batchUpdate
-
models
-
[useOnlineStore]
A method to send batch update, create or delete models in single transaction.
All models saving using this method must have identifiers.
The array which fulfilled the promise may contain the following values:
same model object
- for created, updated or unaltered records.null
- for deleted records.
Parameters:
-
models
DS.Model[] | DS.ModelIs array of models or single model for batch update.
-
[useOnlineStore]
Boolean optionalAllow to explicitly specify online or offline store using independently of global online status.
Returns:
A promise that fulfilled with an array of models in the new state.
createExistingRecord
-
modelName
-
primaryKey
-
[useOnlineStore]
Pushes into store the model that exists in backend without a request to it.
createRecord
-
modelName
-
inputProperties
-
[useOnlineStore]
Create a new record in the current store. The properties passed to this method are set on the newly created record.
Parameters:
Returns:
promise
deleteRecord
-
record
-
[useOnlineStore]
For symmetry, a record can be deleted via the store.
deleteRecord
-
record
-
[useOnlineStore]
Delete all record from the current store.
findAll
-
modelName
-
options
This method returns a fresh collection from the server, regardless of if there is already records in the store or not.
Parameters:
Returns:
promise
findRecord
-
modelName
-
id
-
options
This method returns a record for a given type and id combination. NOTE: this will trigger syncUp twice, this is OK. And since this is a public method, we probably want to preserve this.
Parameters:
Returns:
promise
getCurrentUserName
()
String
Returns current user name. Method must be overridden if application uses some authentication.
Returns:
Current user name. Returns 'userName' as default value if method is not overridden.
getReference
-
type
-
id
-
[useOnlineStore]
Get the reference for the specified record.
Parameters:
Returns:
promise
hasRecordForId
-
modelName
-
inputId
-
[useOnlineStore]
Returns true if a record for a given type and ID is already loaded.
Parameters:
Returns:
normalize
-
modelName
-
payload
-
[useOnlineStore]
Converts a json payload into the normalized form that BaseStore/push:method expects.
Parameters:
Returns:
The normalized payload
peekAll
-
modelName
-
[useOnlineStore]
This method returns a filtered array that contains all of the known records for a given type in the store.
Parameters:
Returns:
peekRecord
-
modelName
-
id
-
[useOnlineStore]
Get a record by a given type and ID without triggering a fetch.
Parameters:
Returns:
Record
push
-
data
-
[useOnlineStore]
Push some data for a given type into the store.
Parameters:
pushPayload
-
modelName
-
inputPayload
-
[useOnlineStore]
Push some raw data into the store.
query
-
modelName
-
query
Query for records that meet certain criteria. Resolves with DS.RecordArray. For more information see query method of DS.Store.
Parameters:
Returns:
promise
query
-
modelName
-
query
Query for record that meet certain criteria. Resolves with single record.
Parameters:
Returns:
promise
recordIsLoaded
-
modelName
-
id
-
[useOnlineStore]
This method returns if a certain record is already loaded in the store.
Parameters:
Returns:
serializerFor
-
modelName
-
[useOnlineStore]
Returns an instance of the serializer for a given type.
Parameters:
Returns:
Serializer
unloadAll
-
modelName
-
[useOnlineStore]
This method unloads all records in the store.
Properties
_offlineSchema
Object
private
Store offline schemas for all databases.
Default: 'Schema of 1 version for internal models of addon'
dexieService
Offline.DexieService
Instance of dexie service.
offlineModels
Object
Add model names that be loaded from offline store.
Default: {}
Example:
// app/services/store.js
...
offlineModels: {
myModel: true,
},
...
offlineSchema
Object
Set schema for your database.
Example:
// app/services/store.js
...
init() {
this.set('offlineSchema', {
<name of database>: {
<number of version>: {
<name of model>: <table definition>,
},
},
dbName: {
1: {
modelName: 'id,attribute1,attribute2,belongsToRelationship1,belongsToRelationship2,*hasManyRelationship1,*hasManyRelationship2',
changedModelName: 'id,attribute1,attribute2',
thisModelWillBeRemovedInNextVersion: 'id,attribute1',
},
2: {
newModelName: 'id,attribute1',
changedModelName: 'id,attribute1,attribute3,attribute4',
thisModelWillBeRemovedInNextVersion: null,
},
},
});
return this._super(...arguments);
},
...
offlineStore
DS.Store
Store that use for making requests in offline mode. By default it is set to global instane of LocalStore class.