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

$joinEager does not using join at total data #85

Closed
taufiqurrohmansuwarto opened this issue Mar 6, 2020 · 2 comments
Closed

$joinEager does not using join at total data #85

taufiqurrohmansuwarto opened this issue Mar 6, 2020 · 2 comments

Comments

@taufiqurrohmansuwarto
Copy link

when using $joinEager count doesnt use join in total (count) but when im using $joinRelation the count is using inner join. Is this bug? it always give me error when i tried filter from $eager column

@dekelev
Copy link
Member

dekelev commented Mar 6, 2020

This is the expected behavior. what are you trying to achieve and what errors do you get? please share detailed examples.

@taufiqurrohmansuwarto
Copy link
Author

taufiqurrohmansuwarto commented Mar 6, 2020

heres my table
image

and heres my model (kamus)
static get relationMappings() {
const tipeKamusModel = require("./tipe-kamus.model");
const subKamusModel = require("./sub-kamus.model");
const skpdModel = require("./skpd.model");

return {
  tipeKamus: {
    modelClass: tipeKamusModel,
    relation: Model.BelongsToOneRelation,
    join: {
      from: "kom.kamus.tipe_kamus_id",
      to: "kom.tipe_kamus.id"
    }
  },
  subKamus: {
    modelClass: subKamusModel,
    relation: Model.HasManyRelation,
    join: {
      from: "kom.kamus.id",
      to: "kom.sub_kamus.kamus_id"
    }
  },
  skpd: {
    modelClass: skpdModel,
    relation: Model.BelongsToOneRelation,
    join: {
      from: "kom.kamus.skpd_id",
      to: "ref.skpd.id"
    }
  }
};

}

my goal is to get data where kamus.skpd_id ilike 'something%' but include tipeKamus and skpd and kamus.skpd_id is null of course.

my current query is {
$eager : '[tipeKamus]',
$joinEager : '[tipeKamus,skpd],
'skpd.id' : {
$ilike : 'something%',
}
}

it giving me error because in count there isnt column skpd.id

well what a shame i got a solution.. now its working. im sorry

{

$eager: '[tipeKamus, skpd]',
$joinEager: '[tipeKamus,skpd]',
$or: [
{
skpd_id: {
$null: true,
},
},
{
skpd_id: {
$ilike: 123%,
},
},
],
}

you can close . thx

@dekelev dekelev closed this as completed Mar 6, 2020
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

2 participants