question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

5.12.6 dropped support for 4.4 projection expression

See original GitHub issue

critical bug

What is the current behavior?

mongoose version 5.12.6 dropped support for MongoDB 4.4 projection expressions. In version 5.12.5 everything works as expected.

Reproduce script:

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const dbConnection = require('./conn')

const TestSchema = new Schema({
    field: {
        subField: String
    }
});

TestSchema.statics.getSubField = function () {
    return this.findOne({}, {
        subField: '$field.subField'
    }).lean().exec();
}

async function test () {
    const connection = await dbConnection();
    const TestModel = connection.model('TestModel', TestSchema);
    const newTestModel = new TestModel({field: {subField: 'schema sub field value'}});
    await newTestModel.save();

    const res = await TestModel.getSubField();
    console.log(res.subField);

    await TestModel.deleteMany({}).exec();
}

test();

With version 5.12.5 console output:

/usr/bin/node /home/tom/WebstormProjects/test/model.js schema sub field value

With version 5.12.6 console output:

/usr/bin/node /home/tom/WebstormProjects/test/model.js undefined

same happens with find

What is the expected behavior? the projection in find and findOne queries, should support aggregation projection expressions, as in 5.12.5 and MongoDB 4.4

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version. Node.js - 14.16.1 Mongoose - 5.12.6 MongoDB - 4.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
vkarpov15commented, May 13, 2021

I took a closer look and you’re right @tomgrossman , I’m very sorry for the difficulty. We made this fix in #10142 as a precaution, but you’re right that it also hides a useful feature. We will undo this change and release the fix in v5.12.9 👍

1reaction
IslandRhythmscommented, May 4, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Projection expressions - Amazon DynamoDB
A projection expression is a string that identifies the attributes that you want. To retrieve a single attribute, specify its name. For multiple...
Read more >
mongoose/CHANGELOG.md at master - GitHub
fix(schema): disallow using schemas with schema-level projection with map ... BREAKING CHANGE: drop support for Model#model #8958 AbdelrahmanHafez ...
Read more >
afman63-143.pdf - Air Force
This Air Force (AF) Manual (AFMAN) implements and identifies Centralized Asset. Management (CAM) procedures referenced in Air Force ...
Read more >
notice of proposed rulemaking - Mercatus Center
CHAPTER 1. INTRODUCTION. 1.1. PURPOSE OF THE DOCUMENT. This technical support document (TSD) is a stand-alone report that provides the technical.
Read more >
View Publication - Defense Contract Management Agency
Sample Supporting Contract Administration Delegation Format ... Removed from military flight orders for cause.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found