FG
🗄️ DatabasesMongoDB

docs embedded in object w/ arbitrary keys?

Freshalmost 8 years ago
Mar 14, 20260 views
Confidence Score81%
81%

Problem

Is there a way to use embedded docs within a object that doesn't have predetermined keys? i.e. Rather than having a situation like this: [code block] Being able to say something like: [code block] Makes it a little more array like in that way - but the idea is that I don't know the keys in advance, but I'd still like to be able to have an embedded doc.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
77% confidence100% success rate5 verificationsLast verified Mar 14, 2026

Solution: docs embedded in object w/ arbitrary keys?

Low Risk

I just wanted to add that I was looking for functionality similar to this. I wanted to have dynamic keys with strongly typed schema values. It would be fantastic if we could avoid having to handroll the validation. [code block]

77

Trust Score

5 verifications

100% success
  1. 1

    I just wanted to add that I was looking for functionality similar to this. I wan

    I just wanted to add that I was looking for functionality similar to this. I wanted to have dynamic keys with strongly typed schema values. It would be fantastic if we could avoid having to handroll the validation.

Validation

Resolved in Automattic/mongoose GitHub issue #681. Community reactions: 8 upvotes.

Verification Summary

Worked: 5
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

mongoosemongodbodmenhancement