Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fature/bug: databaseless facade on server-side mongoose #8237

Closed
captaincaius opened this issue Oct 11, 2019 · 1 comment
Closed

fature/bug: databaseless facade on server-side mongoose #8237

captaincaius opened this issue Oct 11, 2019 · 1 comment
Labels
refactor This is a purely internal change for making Mongoose internals easier to understand and work with
Milestone

Comments

@captaincaius
Copy link
Contributor

Do you want to request a feature or report a bug?

feature

but in reality it's a little bit from column A, a little bit from column B

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce.

captainlocal@cappielappiebuntu:~/dev/mongooseygoose/mongoose$ node
> const goosey = require('./lib');
undefined
> const Document = goosey.Document
undefined
> const intentUserDoc = new Document({}, { name: String });
TypeError: Cannot read property 'options' of undefined
    at new Document (/home/captainlocal/dev/mongooseygoose/mongoose/lib/document.js:83:34)
> 

What is the expected behavior?

server-side behaves the same way as client-side (i.e. doesn't crash)

tl;dr from below - requresting something like this that works on both normal mongoose and mongoose/browser:

const User = mongoose.ModelWithoutDB(UserSchema);
const user = new User();

I know it sounds silly to want this on the server-side, but SSR is the motivation. While working on the PR for #7219 I realized that when replacing references to my own 'wb-mongoose-browser' module with 'mongoose' itself, all the sudden I got that error above.

This is because on the SSR build, even though the codebase is using browser syntax, webpack grabs the normal mongoose instead of the 'browser' key in package.json (it targets 'node' after all). As a workaround, you can use resolve.alias in webpack, but it would be much nicer if it wasn't necessary.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
node 10, mongoose master

@vkarpov15 vkarpov15 added this to the 5.7.6 milestone Oct 17, 2019
@vkarpov15 vkarpov15 added the refactor This is a purely internal change for making Mongoose internals easier to understand and work with label Oct 17, 2019
vkarpov15 added a commit that referenced this issue Oct 20, 2019
@captaincaius
Copy link
Contributor Author

\o/ Legend! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor This is a purely internal change for making Mongoose internals easier to understand and work with
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants