-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can i use mongodb aggregate with lb4? #2021
Comments
Something like:
|
Thank you @octisfall. |
Thank you @octisfall I had the same question and that solution works as I need |
Unhandled error in GET /test: 500 Error: MongoDB connection is not established What is wrong? |
@onkelfunny I have same error with first request, further it works fine. Don't know related it with my solution or not |
@octisfall its not working if the first request is the aggregation request. when I call first another url it works. |
@onkelfunny please create a new issue, maybe loopback contributers will help. I'm too interesting with this |
Thank you @octisfall. I solved the first access issue using this code: I hope it helps. |
Hi I found, 500 TypeError: Cannot read property 'settings' of undefined
Error: |
Hi @octisfall , My code is for aggregation is below
I'm getting the below error. --- Database in local Mode --- |
@sureshkodur , hi have you found a solution? Here is my code:
if (!repository.dataSource.connected) await repository.dataSource.connect();
repository.dataSource.connector!.client.db(repository.dataSource.settings.database).command({
{
aggregate: "Transaction",
pipeline: [
{ "$match": {} }
],
cursor: {}
}
}, {}, (error: any, documents: any) => {
//...
});
if (!repository.dataSource.connected) await repository.dataSource.connect();
repository.dataSource.connector!.client.db(repository.dataSource.settings.database).collection(repository.modelClass.name).aggregate([
{ "$match": {} }
], {}).toArray((error: any, documents: any[]) => {
//...
}); I also tried to run your code, but got the same error as you. |
@likexoo , Yes. I found solution. I did exact what you did, and it worked |
See also my proposal in #2807 (comment), it offers slightly different code. I opened a new issue to describe the more generic feature we are looking for - the ability to execute raw MongoDB queries. See #3342 It would be great if you can up-vote the issue by adding a 👍 reaction (not a comment please, see https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/), that way we will know how many people are asking for this particular feature. I am closing this issue as a duplicate. |
repository.modelClass.name `
|
Does anyone know how to convert |
How can i use mongodb find or aggregate command with lb4?
Where is example?
The text was updated successfully, but these errors were encountered: