Given a table with a column of type jsonb[], how do I insert a json array into the column? 
Using the provided formatters :array, :json won't work in this instance - unless I am missing the correct combination or something.
const links = [
    {
        title: 'IMDB',
        url: 'https://www.imdb.com/title/tt0076759'
    },
    {
        title: 'Rotten Tomatoes',
        url: 'https://www.rottentomatoes.com/m/star_wars'
    }
];
 const result = await db.none(`INSERT INTO tests (links) VALUES ($1:json)`, [links]);
                You do not need the library's :json filter in this case, as you need an array of JSON objects, and not a JSON with an array of JSON objects.
The former is formatted correctly by default, which then only needs ::json[] type casting:
    await db.none(`INSERT INTO tests(links) VALUES($1::json[])`, [links]);
Other Notes
null, no point storing the result in a variable.pg-promise does not have any :array filter, see supported filters.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With