0

I have an object whose column refers to a Json type.

How do I perform a query inside the Json column using id for example?

Model

 @column({
    prepare: (value: Array<object>) => JSON.stringify(value),
    consume: (value: string) => JSON.parse(value),
  })
  public armazenado: object

Controller

const items = await Armazempredio.query().select('*')
      .with('armazenado', builder => {
        builder.where(Database.raw(`JSON_CONTAINS(id, '["0001"]')`))
      })

1 Answer 1

1

Resolver with

@column({
    prepare: (value: Array<object>) => JSON.stringify(value),
    consume: (value: string) => JSON.parse(value),
  })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.