A similar question was asked here, but the one accepted answer doesn't really answer the question.
Using AngularFire, is it possible to to create relational-style databases? Or access the UniqueIDs?
When adding nested items to Firebase via AngularFire, each item is actually set under another index numbered numerically.
Because of this, I'll need to reference the user's products with the following relative url:
users/:id/products
My question is, once I have created a user (or anything for that matter), how do I get the index value?
// Get the users
var ref = new Firebase('https://myapp.firebaseio.com/users')
var promise = angularFire(ref, $scope, 'users', {})
promise.then(function() {
// Can I get the ID from here somehow?
})
// Users saves a product
id = null // ???
var product = {
name: 'new product',
desc: 'this is a new product'
}
var ref = new Firebase('https://myapp.firebaseio.com/users/' + id + '/products')
var promise = angularFire(ref, $scope, 'products', {})
promise.then(function() {
$scope.products.push(product)
})
Update
To clarify, this isn't a question about user authentication. I already have that taken care of. Sorry for the confusion.
I've just run into a brick wall when I start making things "under" other things in Firebase. Doesn't matter if it's user
s or giraffe
s.
If I make "Stores," each Store has "Products" (let's say.)
I'd like to be able to retrieve them with
stores/{storeId}/products
But the storeId
would ideally be the index ID that is created from AngularFire (See the picture I have attached). The trouble is, AngularFire just creates this ID without letting me know about it.
If I had some success function like
success: function(response) {
$scope.store.id = response.indexId
}
That would make the most sense, but it doesn't appear AngularFire is prepare this very needed functionality. Prove me wrong, please. :)