When i was working with firebase, adding new subcollection to existing collection was preety easy:
db.collection('SOME_COLLECTION').doc('someId').collection('SOME_COLLECTION_2').add({ some: object })
with this one line i've create many of the subcollections. But how to do this with simple mongodb and nodejs/typescript?
I try in this way:
const result = await db.collection(COLLECTIONS.USERS).findOne({ _id: new ObjectId(id)}).//error
but i can't call another collection function to create him.
So I need a help, can someone tell me how to create subcollection in mongodb?
Thanks for any help!
PS. or is maybe a better approach with using subcollection in mongodb?