How to get file image url when using query.aggregate
with lookup
?
When I perform a lookup I get this in place of the file hence I cannot call file.url()
b9...9dd3d9f7c........da477cc053_pHL........DAQJLhtxAUA6b.png
How to get file image url when using query.aggregate
with lookup
?
When I perform a lookup I get this in place of the file hence I cannot call file.url()
b9...9dd3d9f7c........da477cc053_pHL........DAQJLhtxAUA6b.png
can you give full code for this?
const query = new Moralis.Query(Moralis.Object.extend('Comments'))
const pipeline = [
{ match: { post_id: id } },
{
//First lookup to get username
lookup: {
from: '_User',
localField: 'user_id',
foreignField: '_id',
as: 'user',
},
},
{
//second lookup to get "avatar_image"
lookup: {
from: 'UserProfile',
localField: 'user_id',
foreignField: 'user_id',
as: 'profile',
},
},
]
const results = await query.aggregate(pipeline)
In the UserProfile Class there is a column โavatar_imageโ with a type of file. I get this data back however not in a Moralis file type
How are you saving the avatar_image? Are you using Moralis.File()
?
Yes, the avatar_image is saved using Moralis.File()
What does avatar_image look like in your database / server dashboard?