MongoEngine / MongoEngine/mongoengine

Doubt: How to specify collation on Documents(Collection)?

Open
#2,346 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

I have the following class:

class Subject(me.Document):
    name = me.StringField(unique=True)
    topic = me.StringField(required=True, choices=('Language', 'Other'))
    isCompulsory = me.BooleanField(required=True, default=False)

    meta = {
        'collation': {
            'locale': 'en',
            'caseLevel': False
        }
    }

The Docs do not provide any example.
I have two problems:

  1. How can I make choices to be case-insensitive.
  2. I am able to insert values like physics, Physics in name field. How to make DB treat them as same?

NB: I have dropped Collection (using MongoDB Compass) before trying this.
Info:

  • MongoDB Version : 4.0.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository file, test, or entry point; start by locating the documentation for Document/Collection collation and StringField choices, then verify the MongoDB 4.0.3 behavior described. Done means the documentation explains case-insensitive choices and duplicate handling for name, with an example covering the stated meta configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
database, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.