Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
Empty return when adding an object to_.transform in Lodash

I'm using Lodash to do some work on our object. So I had a little problem that I can't solve.

I'm trying to add the result of a query, in the _.transform array. But without success.

The return is empty.

I did some tests using the console.log and the value is shown normally.

const result = _.transform(data.items, async  (r: any, v: any) => {
      let data = await Cliente.query().where('id', '=', v.codiPsv).orderBy('validade', 'asc').first()
      if (data){
        console.log(data.serialize()) --> Show object
        r.push(data.serialize())
        console.log(0)
      }
    })

    console.log(result)   --> empty
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Resolved

    const cods = _.map(data.items, 'codiPsv')
    const items = await Cliente.query().whereIn('id', cods).orderBy('validade', 'desc')
    const itemsSerelialize = items.map((item) => item.serialize())

    const result = _.transform(data.items, async (r: any, v: any) => {
      const item = _.filter(itemsSerelialize, {'id':v.codiPsv}).slice(-1).pop()
      if ( !_.isUndefined( item )) {
        r.push(item)
      } else {
        console.log(v)
        r.push({'local': 'Indisponível', ...v})
      }
    })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!