dmfay / massive-js

A data mapper for Node.js and PostgreSQL.
2.49k stars 158 forks source link

Disable junctions for insert #550

Closed samjeffress closed 6 years ago

samjeffress commented 6 years ago

Hi, My objects that I'm storing have both standard postgres columns, and jsonb for storing an original request object. I've renamed some columns in my tables to use snake case, and now I have columns that match a nested property name in my object. I'm now getting errors this.records[0][j].map is not a function which is from lib/statement/insert.js -> format function. (it's resolving to string values, which aren't mappable) If I could disable junctions then this wouldn't be an issue - is this available? Thanks Sam

dmfay commented 6 years ago

It is not, but adding an ignoreJunctions option for inserts would be pretty straightforward if you'd like to submit a pull request.

samjeffress commented 6 years ago

Added a pr - https://github.com/dmfay/massive-js/pull/551. I went with deepInsert as the option name because that's talked about in doco rather than the junctions

dmfay commented 6 years ago

Released as 4.7.0, thanks!

samjeffress commented 6 years ago

Pleasure :) thanks for your quick feedback 👍

tylercollier commented 6 years ago

Is there a way to set global config options for massivejs (I looked all through the doc, which is well written and organized, and didn't see it)? I'd like to default { deepInsert: false } everywhere.

dmfay commented 6 years ago

There are global options but that is not one of them. I've been thinking about changing how that's enabled somehow for v5, but I've also been pretty busy. I've just thrown a v5 branch up if you or anyone else wants to make a pull request against it.