Example use
// app/adapters/application.js
import FirestoreAdapter from 'emberfire/adapters/firestore';
export default FirestoreAdapter.extend({
enablePersistence: true,
persistenceSettings: { synchronizeTabs: true }
});
// app/models/article.js
import DS from 'ember-data';
const { attr, belongsTo, hasMany } = DS;
export default DS.Model.extend({
title: attr('string'),
body: attr('string'),
publishedAt: attr('date'),
author: belongsTo('user'),
comments: hasMany('comments', { subcollection: true }),
});
// app/routes/articles.js
import Route from '@ember/routing/route';
import RealtimeRouteMixin from 'emberfire/mixins/realtime-route';
import PerformanceRouteMixin from 'emberfire/mixins/performance-route';
export default Route.extend(RealtimeRouteMixin, PerformanceRouteMixin, {
model() {
return this.store.query('article', { orderBy: 'publishedAt' });
}
});
// app/routes/application.js
import AnalyticsRouteMixin from 'emberfire/mixins/analytics-route';
import Route from '@ember/routing/route';
export default Route.extend(AnalyticsRouteMixin);