MongoDB → PostgreSQL
Scalar types
| BSON type | Postgres type | Notes |
|---|---|---|
ObjectId | uuid or text | Stored as hex string. Use uuid if you plan to keep the ID format. |
String | text | Length-agnostic. Use varchar(n) if you need a limit. |
Int, Long | bigint | Safe default for JS numeric ranges. |
Double, Decimal128 | double precision or numeric | numeric preserves exact precision. |
Boolean | boolean | Direct map. |
Date | timestamptz | Always stored as UTC. |
Binary | bytea | Binary data. |
null | NULL | Column must be nullable. |
Container types
| BSON type | Postgres type | Notes |
|---|---|---|
Object (nested) | Flattened columns or jsonb | Depth ≤ --max-depth → flatten; deeper → jsonb. |
Array<T> | T[] (native array) or jsonb | Homogeneous arrays of scalars → native array; mixed → jsonb. |
Array<Object> | jsonb | Always jsonb — one-to-many relationships aren’t auto-derived. |
Mixed types
If a field has multiple types across documents (e.g., 99%Int, 1% Double), DBdock picks the “widest” compatible Postgres type. You’ll see a warning:
Example
MongoDB:--max-depth 2):
PostgreSQL → MongoDB
Scalar types
| Postgres type | BSON type | Notes |
|---|---|---|
uuid | String | UUID as lowercase hex string. |
text, varchar | String | Direct map. |
integer, bigint | Int / Long | bigint may need Long on 32-bit platforms. |
numeric, decimal | Decimal128 | Exact precision preserved. |
real, double precision | Double | IEEE 754 mapping. |
boolean | Boolean | Direct map. |
date | Date (at midnight UTC) | Date-only types lose time component. |
timestamp, timestamptz | Date | Stored as UTC. |
bytea | Binary | Direct map. |
jsonb, json | Native document | Parsed into MongoDB object. |
Container types
| Postgres type | BSON type | Notes |
|---|---|---|
T[] (array) | Array<T> | Element types mapped individually. |
| Foreign key relations | Option: embed or reference | See below. |
Relationships
DBdock can optionally embed one-to-many relationships into parent documents:- Reference mode (default): stores the FK as-is, creates separate collections.
- Embed mode: pulls child rows into a nested array on the parent document.

