Skip to content

_attachments are removed from exportJSON() output #8924

Description

@len360

Hi,

I am currently using the exportJSON() and importJSON() database methods to perform manual data migrations in my application.

My database schema uses attachments, and I noticed that the _attachments property is removed from the exported JSON data.

Because of this, importing the dump into another database does not seem to preserve attachment metadata, which makes it impossible to use exportJSON() / importJSON() as a complete database migration mechanism when attachments are involved.

Steps to reproduce

  1. Create a database with a collection that has attachments enabled.
  2. Add a document with one or more attachments.
  3. Run:
const dump = await db.exportJSON();
  1. Inspect the exported document.

The _attachments field is missing from the exported data.

Expected behavior

The JSON dump should contain the _attachments property so that a complete database export/import cycle can preserve documents together with their attachments.

Current behavior

The _attachments property is removed during export.

Location in the code

delete docData._attachments;

Could you clarify if this is intentional?

If attachments are intentionally excluded from JSON dumps, would it make sense to document this limitation or provide another export/import mechanism that includes attachments?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions