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.

Avoid id alias globally

See original GitHub issue

Do you want to request a feature or report a bug? bug What is the current behavior? In one of my plugins I’ve set id false to avoid id in all my models, it worked on 5.13.x, but now it’s not working in 6.0.x If the current behavior is a bug, please provide the steps to reproduce.

"use strict";
const mongoose = require("mongoose");
const {Schema, model} = mongoose;
const test = new Schema({
  test: {
    type: Number
  }
});
const test2 = new Schema(
  {
    test: {
      type: Number
    }
  },
  {id: false}
);
mongoose.plugin((schema) => schema.set("id", false));
const Test = model("Test", test);
const newTest = new Test();
console.log(newTest.id);
const Test2 = model("Test2", test2);
const newTest2 = new Test2();
console.log(newTest2.id);

What is the expected behavior? I’d like to be able to set id false globally, instead of using a plugin. For the moment I need a solution to avoid id alias in my models as Schema.set("id", false); is not working in a plugin. What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version. Node 16.8.0 Mongoose 6.0.5 Mongodb atlas 4.4.8

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
vkarpov15commented, Sep 18, 2021

I took a closer look and you’re right, this is a bug. We tried to refactor id to be a plugin in #3936 for 6.0, made a note to undo that refactor, but didn’t get to it. Lessons learned: make a separate issue instead of treating the issue as “done” but relying on a comment as a mental note to self.

We’ll ship 6.0.7 with this fix on Monday 👍

0reactions
chumagercommented, Oct 14, 2021

Hi @vkarpov15 Just like any other sort system, FIFO…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Your AWS account ID and its alias
The account alias must be unique across all Amazon Web Services products. It must contain only digits, lowercase letters, and hyphens. For more...
Read more >
Why does sudo ignore aliases? - Unix & Linux Stack Exchange
This creates a global alias called $ (you can use any word you want) which ends in a space. This causes zsh to...
Read more >
How to best set up command aliases on Linux - Network World
Setting up the most useful aliases on Linux is a mix of what's otherwise annoying to enter, hard to remember or typed way...
Read more >
The Fun of Doing Business Under an Alias or Assumed Name
People may use aliases to conceal their identity but for companies, there are several very legitimate reasons to use an alias or assumed...
Read more >
Create and remove aliases on Mac - Apple Support
In the Finder on your Mac, create an alias to represent a file, folder, app, or disk. Put the alias in a convenient,...
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