Pluck / ids() as Array or Serialize

#1

I am using ids() to get the ids of Pivot Record. Refer to the code below:

const addon = await Addon.query().with('packages')
    .where('id', params.id).firstOrFail()

const package_ids = addon.packages().ids()

In my view I am trying to check If a certain element/value is in package_ids variable. It’s not returning an array or a JSON object. How can I serialize it? I tried using toJSON() / JSON.Stringify(), but nothing seems to work.

0 Likes

#2

It has to be await addon.packages().ids(), basically await is missing

0 Likes