Save array of jsonb in Postgres
See original GitHub issueIssue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
Hi, I have this column
@Column('jsonb', { array: true })
arrayOfJson: {foo: string}[];
and this function
async test() {
const baz = await this.bazRepository.create({
arrayOfJson: [
{foo: 'bar'}
]
})
this.bazRepository.save(baz)
}
The column is created correctly in the database but when I try to save it I am getting this error
QueryFailedError: malformed array literal: "[{"foo":"bar"}]"
It was issued here #204. Am I doing something wrong?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
Working with a JSONB Array of Objects in PostgreSQL
Open pgAdmin and create a database as desired. · Right-Click on the database name and choose Query Tool. · Run the snippet below...
Read more >Storing JSON Array of Arrays in PostgreSql - Stack Overflow
First statement returns two rows, one for each array. select jsonb_array_elements(msg->'root') as el from js. Then returns each individual ...
Read more >How to keep array fields in PostgreSQL jsonb
My question is: Is there a way to store PostgreSQL arrays faithfully in JSONB objects? postgresql · json · array.
Read more >Documentation: 15: 8.14. JSON Types - PostgreSQL
The jsonb data type supports array-style subscripting expressions to extract and modify elements. Nested values can be indicated by chaining subscripting ...
Read more >How to Query JSONB Array of Objects in PostgreSQL
The syntax for Inserting values in the database is as follows: INSERT INTO TABLE_NAME(col1, col2, col3) VALUES(val1, val2, val3);. It is now ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lukasfrana Removing array:true from options works for me perfectly.
where Foo is another interface with multiple keys. No problem with saving as well.
But
simple-json
stores as a string rather than asjsonb
?