Last active
October 4, 2017 09:09
-
-
Save benbonnet/7a2262157754e833fea5f5f7e59b7951 to your computer and use it in GitHub Desktop.
Firestore.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Final expectation : being able to reference items in subcollections and retrieve | |
// them without duplicating them in the subcollection, by simply querying the parents subcollection | |
// Those two works ok | |
var docRef = db.collection('users').doc('alovelace'); | |
var setAda = docRef.set({ | |
first: 'Ada', | |
last: 'Lovelace', | |
born: 1815 | |
}); | |
var docRef = db.collection('items').doc('demo_item'); | |
var setAda = docRef.set({ | |
title: 'ok', | |
content: 'small desc.', | |
position: { | |
x: 0, | |
y: 10, | |
w: 100, | |
h: 200 | |
} | |
}); | |
// Expected : having an entry in the items subcollecitons (users/alovelace/items/[demo_item] ?) | |
// Result : nothing in users/alovelace/items/ | |
var ref = db.collection('users').doc('alovelace').collection('items').doc('demo_item'); | |
// I don't get anything with the above command | |
// I see you can pass an object as below : | |
var ref = db.collection('users').doc('alovelace').collection('items').doc({ref: 'demo_item'}); | |
// But it does not help at all, as I'd have to query again to get the 'demo_item' ref | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment