parse-community / parse-community/parse-server

Index on default field not created correctly

Open
#6,834 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

  • This isn't a vulnerability disclosure, if it is please follow our security policy.

  • You're running version >=2.3.2 of Parse Server, we can't accept issues for very outdated releases, please update to a newer version.

  • This isn't a question, if you need if you have questions about code please use Stack Overflow with the parse-platform tag & other questions can be posted on the community forum.

  • You've searched through existing issues, your issue may have been reported or resolved before.

Discussion started on https://community.parseplatform.org/t/how-to-add-index-on-createdat-and-updatedat-if-possible/586/5 @davimacedo and I feel this is a bug

We tried to add an index to createdAt by post to /schemas/${className}

    indexes: {
            _createdAt_: {
                createdAt: 1
            },
            _updatedAt_: {
                updatedAt: 1
            }
        }

The post worked. Looking at the MongoDB it seems the indexes are created but on MongoDB it is _created_at and _updated_at. So the index does not work.

image

We tried to do the following but got an error

{
    indexes: {
            _created_at_: {
                _created_at: 1
            },
            _updated_at_: {
                _updated_at: 1
            }
        }
}
{
    “code”: 102,
    “error”: “Field _created_at does not exist, cannot add index.”
}
Environment Setup
  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.11.0
    • Operating System: Mac
    • Hardware: Mac
    • Localhost or remote server? Localhost
  • Database

    • MongoDB version: 4.2.8
    • Localhost or remote server? Mongo Atlas

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

Reproduce the schema POST to /schemas/${className} using Parse Server 2.11.0 with MongoDB 4.2.8, then inspect the resulting index names in MongoDB. Compare the requested createdAt and updatedAt indexes with the generated _created_at and _updated_at fields; done means indexes can be created on the default fields without the nonexistent-field error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
api, backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.