'Mongodb aggregate lookup for merged collections?
Merged queries takes more time for requests, for instance having a username query from user collection and having a query from productpost, costs server process power with more requests sent from userend.
My Q is can we have aggregate function for the latest golang mongodb integration?
Solution 1:[1]
After much time spent on this. The easiest way to do this is via requests than lookups since it will require to go through all documents to find:
Here is mongodb document structure
{"_id":{"$oid":"6198b5cf985bb6b616480463"},"userid":{"$oid":"613dfcca9e7e2014c12dfeef"},"attach":"[\"https://image.bitfinicon.com/be/images/2021/10/OTKAR2021-10-0222-40-33_5877034727566088.png\"]","title":"I'm title here"}
Then in the JS you call requests (Using Sveltekit new generation):
<div class="author-name">
<!-- DONEAPPLYCHANGES DONE ALDOLAP -->
{#if config.name === 'aldolap'}
<div class="author-name-prefix">{product.price} TL</div>
{/if}
{#await getuserhere2(product.userid)}
<p>...waiting</p>
{:then number}
<a href={`/u/` + number.username + `_` + `${product.userid}`} >{number.username}</a>
{:catch error}
<p style="color: red">{error.message}</p>
{/await}
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Bitfinicon |