Skip to content
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

db.rel.findHasMany is not working #120

Open
courageDeveloper opened this issue Dec 19, 2019 · 3 comments
Open

db.rel.findHasMany is not working #120

courageDeveloper opened this issue Dec 19, 2019 · 3 comments

Comments

@courageDeveloper
Copy link

Finding it difficult to implement db.rel.findHasMany. I have followed the examples and i still can't get it to perform what i want it to do. Can i get a detailed example of how it can be implemented?

@monsieurpigeon
Copy link

same still not working for me, i'm trying to use queryInverse, added the index, but still not functioning.
Possible to get more examples ?

@monsieurpigeon
Copy link

monsieurpigeon commented Mar 4, 2023

db.rel.findHasMany is actually working with an index

    products_1.map(async (product: Product) => {
      return {
        ...product,
        tasks: await relDB.rel
          .findHasMany("tasks", "product", product.id)
          .then((result) => result.tasks),
      };
    })
  );

with this schema

{
    singular: "product",
    plural: "products",
    relations: {
      tasks: {
        hasMany: { type: "task", options: { queryInverse: "product" } },
      },
    },
  },
  {
    singular: "task",
    plural: "tasks",
    relations: { product: { belongsTo: "product" } },
  }

and this index

relDB.createIndex({ index: { fields: ["data.product", "_id"] } });

But i would expect from queryInverse that it does this more efficiently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants