Coder Social home page Coder Social logo

Comments (1)

vinczedani avatar vinczedani commented on July 20, 2024

Hi @Pikachews
I tested your issue and it is true that it prints an empty Object, so I created a native mongoose test to see how it works there.

my mongoose schema:

const testSchema = new mongoose.Schema({
  nested: {
    value: String,
  },
  numeric: Number,
});

export const mongooseModel = mongoose.model('Test', testSchema);

my test code:

const nativeMongoose = await Test.create({
  numeric: 1,
});

 console.log(JSON.stringify(nativeMongoose, null, 2));
 console.log(nativeMongoose['nested']);

 const foundNative = await Test.findOne({
   numeric: 1,
 });

 console.log(JSON.stringify(foundNative, null, 2));
 console.log(foundNative['nested']);

That printed out the following:

{
  "__v": 0,
  "numeric": 1,
  "_id": "59c2287fe89e526d3f9ccb07"
}
{}
{
  "_id": "59c2287fe89e526d3f9ccb07",
  "numeric": 1,
  "__v": 0
}
{}

So the native mongoose implementation prints nested objects too. We don't want to differ from their functionality, even if it is not completely logical so I am closing this issue.
Thanks for using Typegoose and reporting your issues.
Cheers,
Daniel

from typegoose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.