Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Sichere ProgrammierungTest Planning: Before I Start Testing(02.10.2026 um 03:06 Uhr)
•
Sichere ProgrammierungWhat Jev Got Right: Judgment as an Interface, Not a Paragraph(02.10.2026 um 03:10 Uhr)
••
Sichere ProgrammierungYield Strategy Optimization Report: MEXC(02.10.2026 um 03:16 Uhr)
••
Sichere ProgrammierungHow to Build a Voice-Over Tool for YouTube Videos(02.10.2026 um 03:19 Uhr)
••
Sichere ProgrammierungWhy auto_prepend_file and On-Server WordPress Firewalls Cause TTFB Lag(02.10.2026 um 03:20 Uhr)
•
Sichere ProgrammierungSilent Cron Runs: A Backend Metrics Dashboard Beyond API Failures(02.10.2026 um 03:20 Uhr)
•
Sichere ProgrammierungI Analyzed 2,315 Wordle Answers to Find the Best Starting Words(02.10.2026 um 03:21 Uhr)
•
Sichere ProgrammierungTest Planning: Before I Start Testing(02.10.2026 um 03:06 Uhr)
•
Sichere ProgrammierungWhat Jev Got Right: Judgment as an Interface, Not a Paragraph(02.10.2026 um 03:10 Uhr)
••
Sichere ProgrammierungYield Strategy Optimization Report: MEXC(02.10.2026 um 03:16 Uhr)
••
Sichere ProgrammierungHow to Build a Voice-Over Tool for YouTube Videos(02.10.2026 um 03:19 Uhr)
••
Sichere ProgrammierungWhy auto_prepend_file and On-Server WordPress Firewalls Cause TTFB Lag(02.10.2026 um 03:20 Uhr)
•
Sichere ProgrammierungSilent Cron Runs: A Backend Metrics Dashboard Beyond API Failures(02.10.2026 um 03:20 Uhr)
•
Sichere ProgrammierungI Analyzed 2,315 Wordle Answers to Find the Best Starting Words(02.10.2026 um 03:21 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

📚 Tip and Trick: MongoDB Attribute Pattern 💻

Situation: Single View applications 🔍 Incorporate any type of data 🌐 Dynamic schemas to iterate 🔀 Expressive query language, indexing, aggregation to find, filt…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

Situation:




  • Single View applications 🔍

  • Incorporate any type of data 🌐

  • Dynamic schemas to iterate 🔀

  • Expressive query language, indexing, aggregation to find, filter the data 🔍




Challenge:




  • Diverse Data Types: Reconciling schemas from different systems is hard 🤯

  • Rigid Schemas: Cannot change on schema 📛




Shortcomings:




  • Only can fine-grained data schema 📋

  • Cannot add ad hoc queries 🚫

  • Cannot add secondary indexes 🚫




Solution: MongoDB Documents model 💥




  • Use any type of data (numbers, strings, binary data, arrays) 🔢🔤🔣🔢

  • Dynamic Schemas: Don't need to have all the same fields 🔀

  • Query example: Indexing to find and filter data 🔍

  • Indexing: pet




{
"name": "Peter"
}
{
"name": "Mary",
"pet": "cat"
}







Result:




  • Only can query Mary because she has pet on indexing 😕




Attribute Pattern: 🔑




  • Subset: Big documents with many similar fields 📜

  • Moving subset of data into a key-value sub-document 📂

  • Sort fields in a small subset of documents 🗂️




Advantage:




  • Avoid create a lot of indexes and reduce performance 💪




Attribute Pattern Use Case 1: Insurance Company 🏦




  • Aggregates data from multiple sources into a central place 🌐

  • Get a 360° picture of a customer 🔍

  • Better customer service at a reduced cost 💰

  • Innovate quickly 🚀






Before:




{
release_Italy: ISODate("1977-10-20T01:00:00+01:00"),
release_France: ISODate("1977-10-19T01:00:00+01:00"),
release_UK: ISODate("1977-12-27T01:00:00+01:00"),
}






Index:




{release_Italy: 1}
{release_France: 1}
{release_UK: 1}









After:




{
releases: [
{
location: "USA",
date: ISODate("1977-05-20T01:00:00+01:00")
},
{
location: "France",
date: ISODate("1977-10-19T01:00:00+01:00")
}
],
}






Index:




{ "releases.location": 1, "releases.date": 1}






Non-Deterministic Naming: 🔖




  • Easy to add extra qualifiers 🔍

  • Clearly state relationship of original field and value 📝




{
"specs": [
{ k: "volume", v: "500", u: "ml" },
{ k: "volume", v: "12", u: "ounces" }
]
}






Index




{"specs.k": 1, "specs.v": 1, "specs.u": 1}









Attribute Pattern Use Case 2: Clothing 👕




  • Sizes that are expressed in small, medium, large 📏

  • Some clothing in collection may be expressed in numbers (11, 12, 13) 🔢

  • Characteristics are seldom common across the assets 🎨



Catalog are similar, such as name, vendor, manufacturer, country of origin 🏭




  • Provides good structure for data 🗂️



{
"specs": [
{ k: "size", v: "11", u: "CHINA" },
{ k: "size", v: "large", u: "USA" }
]
}





Index:




{"specs.k": 1, "specs.v": 1, "specs.u": 1}









Reference:



https://www.mongodb.com/developer/products/mongodb/attribute-pattern/

Building with Patterns: The Attribute Pattern



https://www.mongodb.com/solutions/use-cases/single-view

Single View applications



https://www.mongodb.com/blog/post/building-with-patterns-a-summary

Building with Patterns: A Summary



https://www.mongodb.com/blog/post/building-with-patterns-the-approximation-pattern

Building with Patterns: The Approximation Pattern






Editor



Image description



Danny Chan, specialty of FSI and Serverless



Image description



Kenny Chan, specialty of FSI and Machine Learning

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten 📚 Tip and Trick: MongoDB Attribute Pattern 💻

Thematisch verwandte Begriffe: Trick, MongoDB, Attribute, Pattern · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag