The adapter supports hasMany
and belongsTo
. However, there are some optional configs that you can make use of to support your needs.
The optional configs are available by passing it as a param.
import Model, { attr, belongsTo } from '@ember-data/model';
export default class UserModel extends Model {
@attr name;
@belongsTo('country', { isRealtime: true }) country;
}
Indicates if the record will update in realtime
Type: boolean
Hook for providing a custom collection reference.
Type: function
Params:
Name | Type | Description |
---|---|---|
db | Firestore |
|
record | Object | The record itself |
The optional configs are available by passing it as a param.
import Model, { attr, hasMany } from '@ember-data/model';
import { query, where } from 'ember-cloud-firestore-adapter/firebase/firestore';
export default class GroupModel extends Model {
@attr name;
@hasMany('post', {
isRealtime: true,
filter(reference) {
return query(reference, where('status', '==', 'approved'));
}
})
approvedPosts;
}
If the document contains a field that matches your referenceKeyName
, it'll fetch that one instead.
Indicates if the record will update in realtime after creating it
Type: boolean
Hook for providing a custom collection reference.
Type: function
Params:
Name | Type | Description |
---|---|---|
db | Firestore |
|
record | Object | The record itself |
Hook for providing the query for the collection reference
Type: function
Params:
Name | Type | Description |
---|---|---|
reference | CollectionReference |
Will contain the return of buildReference when overriden. Otherwise, it will be provided by the adapter itself. |
record | Object | The record itself |