mardi 23 février 2016

Emberfire saving record under custom key

Is it possible to save a new record using createRecord() and specify a custom key to save that new record under? At the moment when using createRecord() it's the same as using push() in the javascript framework.

Obviously the following:

var myObj = this.store.createRecord('myObj', {
    attr1: "Test"
})
myObj.save();

creates a new record with a key similiar to -KBCqhu4mhvl6xNfSRD3.

My problem is that there are some of my keys in different endpoints where I would like the keys to be the same as the user's id.

To clarify further, here is an example of what I would like my Firebase structure to end up as:

FB
|
|
users-- 
|       |
|       userID1--
|       |        |
|       |        userAttr1
|       |        |
|       |        userAttr2
|       |
|       userID2--...
|
drivers--
         |
         userID1--
                  |
                  driverAttr1
                  |
                  driverAttr2

Let me know if I can clarify further




Aucun commentaire:

Enregistrer un commentaire