Coder Social home page Coder Social logo

Comments (2)

szokodiakos avatar szokodiakos commented on July 20, 2024

Hello. That is an interesting finding. Actually Typegoose under the hood composes a Mongoose schema using the props defined by your class, no more. It wont scan the db for pre existing fields, so it is really interesting.

Anyway I will try to reproduce the problem when I will have the time and will get back to you with the results.

from typegoose.

vinczedani avatar vinczedani commented on July 20, 2024

Hi @pgsfredda
Based on your edit in your description I close this issue.
I paste your solution so if someone from google ends up here, will find it faster.
Cheers,
Daniel

EDIT (06/oct/2017):
I found the solution using the 'projection' parameter of the 'find' method.
I don't know if there is a typegoose method or a better idea to compose the projection string:

let proj = Object.keys(UserModel.schema.obj).join(' ');
public index(req: Request, res: Response, next: NextFunction) {
       let proj = Object.keys(UserModel.schema.obj).join(' ');

        UserModel.find({}, proj, (err, data) => { 
            if(err) {
                res.status(200).json({msg: 'err', "err": err});
                return next(err);
            }
            res.status(200).json({msg: 'ok', "data": data});
           // prints:
           // {"msg":"ok","data": [{"_id":"57669d50a87cfa704393bf54","username":"myusername","email":"[email protected]"}]}
        });

    }

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.