Skip to content
This repository has been archived by the owner on Apr 19, 2019. It is now read-only.

Feature: Support of Object Data Mapper (ODM) #175

Closed
bdiz opened this issue Jun 21, 2018 · 3 comments
Closed

Feature: Support of Object Data Mapper (ODM) #175

bdiz opened this issue Jun 21, 2018 · 3 comments

Comments

@bdiz
Copy link

bdiz commented Jun 21, 2018

Hello, this is somewhat related to my earlier comments in #167. What I've come to learn is that what I was looking for in my app is an ODM layer on top of Vuex, Firestore, vuexfire. Inspired by Mongoid, something like:

// src/store/models/todo.js
import Vue from 'vue';
import { documentMixin } from 'vuexfire';
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 can operate on a todo object ie let todo = Todo.create(...); todo.updateAttribute(...); todo.upsert(...); todo.delete(); todo.category; todo.text; todo.subTasks; todo.subTasks.create(...);.

I've built a working version of this using dynamic modules under the hood, but it needs a lot of work. Before I spend more time on it I thought I'd ask if this was on the road map of vuexfire? Or if there are other libraries you may know about that might just require a vuexfire "adapter" to get working? If their is no such ODM for even firebase, which has been around for a while, is there a flaw in my reasoning as to this being a missing level of abstraction for our Vuex/Firestore apps?

@ClickerMonkey

This comment has been minimized.

@motin
Copy link

motin commented Sep 19, 2018

Perhaps look into https://github.com/fiery-data/fiery-vuex - this has exactly what you're looking for.

Looks good. A more general, non-firestore-specific library to look into is https://vuex-orm.github.io/vuex-orm/ which may be able to be used with Firestore as a persistency backend using vuexfire / fiery.

@posva
Copy link
Owner

posva commented Apr 19, 2019

This is something that goes beyond the scope of vuefire/vuexfire. It could be useful but only for a small amount of people using it, I'm okay with having some discussion around it (in vuefire repo) but I definitely don't have the bandwidth to produce such thing.
Theoritically it could be built as a plugin once vuejs/vuefire#240 or vuejs/vuefire#153 get implemented

I'm archiving vuexfire since everything is moved to vuefire, so I'm closing this

@posva posva closed this as completed Apr 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants