1

As I'm coding a Vue app using Firestore, I'm feeling the need for an ODM in the vein of Mongoid.

I could see something like:

// src/store/models/todo.js
import Vue from 'vue';
import documentMixin from '../documentMixin';
import SubTask from './sub-task';

export default Vue.extend({
  mixins: [
    documentMixin('todo', {
      fields: ['text'],
      embeddedIn: 'category',
      embedsMany: { // uses firestore subcollection
        subTasks: { model: SubTask }
      }
    })
  ],
  computed: {
    // ...
  }
});

With this you could operate on a todo object ie let todo = Todo.create(...); todo.updateAttribute(...); todo.upsert(...); todo.delete(); todo.text; todo.subTasks; todo.subTasks.create(...); like in Mongoid. I actually have a very rough version of this that works using Vuex dynamic modules.

Anybody know of such libraries? I could see that something would not exist yet for Vue/firestore as firestore is still in beta. But I'm wondering if their is a flaw in my thinking that an ODM is needed here because my searches do not find any libraries for Vue/firebase.

btd
  • 404
  • 3
  • 12
  • I'd like to replace my implementation with an open source option if possible. – btd Jun 21 '18 at 14:38
  • https://github.com/vuejs/vuefire?? – Renaud Tarnec Jun 21 '18 at 14:52
  • 1
    I'm actually using vuexfire under the hood of this. vuefire and vuexfire are for binding firebase/Firestore snapshots to Vue data or Vuex state. To my knowledge there is no ODM features in these projects ie relation/association specification for purpose of abstracting and DRYing up database interactions. – btd Jun 22 '18 at 01:54

0 Answers0