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

some of the functions is missing with ^5.2.16 #7043

Closed
deckyfx opened this issue Sep 24, 2018 · 3 comments
Closed

some of the functions is missing with ^5.2.16 #7043

deckyfx opened this issue Sep 24, 2018 · 3 comments

Comments

@deckyfx
Copy link

deckyfx commented Sep 24, 2018

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

What is the current behavior?

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

What is the expected behavior?

Please mention your node.js, mongoose and MongoDB version.

[BUG]
Version: ^5.2.16
MongoDB: not yet connected
Current behavior: some of the functions is missing, for example mongoose.model
Expected: model<T extends Document>(name: string, schema?: Schema, collection?: string, skipInit?: boolean): Model<T>;

the types definition is working, but when compiled / used, it crash in runtime since model function is missing

here is the contents of import * as mongoose

{ PromiseProvider:
   { _promise: [Function: callIntoRenderer],
     get: [Function: callIntoRenderer],
     set: [Function: callIntoRenderer] },
  Error: [Function: callIntoRenderer],
  Schema: [Function: callIntoRenderer],
  Types:
   { Array: [Function: callIntoRenderer],
     Buffer: [Function: callIntoRenderer],
     Embedded: [Function: callIntoRenderer],
     Document: [Function: callIntoRenderer],
     DocumentArray: [Function: callIntoRenderer],
     Decimal128: [Function: callIntoRenderer],
     ObjectId: [Function: callIntoRenderer],
     Map: [Function: callIntoRenderer],
     Subdocument: [Function: callIntoRenderer] },
  VirtualType: [Function: callIntoRenderer],
  SchemaType: [Function: callIntoRenderer],
  utils:
   { toCollectionName: [Function: callIntoRenderer],
     deepEqual: [Function: callIntoRenderer],
     last: [Function: callIntoRenderer],
     clone: [Function: callIntoRenderer],
     promiseOrCallback: [Function: callIntoRenderer],
     options: [Function: callIntoRenderer],
     random: [Function: callIntoRenderer],
     merge: [Function: callIntoRenderer],
     toObject: [Function: callIntoRenderer],
     isObject: [Function: callIntoRenderer],
     isPOJO: [Function: callIntoRenderer],
     args: [Function: callIntoRenderer],
     tick: [Function: callIntoRenderer],
     isMongooseObject: [Function: callIntoRenderer],
     expires: [Function: callIntoRenderer],
     PopulateOptions: [Function: callIntoRenderer],
     populate: [Function: callIntoRenderer],
     getValue: [Function: callIntoRenderer],
     setValue: [Function: callIntoRenderer],
     object:
      { vals: [Function: callIntoRenderer],
        shallowCopy: [Function: callIntoRenderer],
        hasOwnProperty: [Function: callIntoRenderer] },
     isNullOrUndefined: [Function: callIntoRenderer],
     array:
      { flatten: [Function: callIntoRenderer],
        unique: [Function: callIntoRenderer] },
     buffer: { areEqual: [Function: callIntoRenderer] },
     getFunctionName: [Function: callIntoRenderer],
     decorate: [Function: callIntoRenderer],
     mergeClone: [Function: callIntoRenderer],
     each: [Function: callIntoRenderer],
     noop: [Function: callIntoRenderer] },
  Document: [Function: callIntoRenderer] }
@vkarpov15
Copy link
Collaborator

import * as mongoose is not supported. The only ES6 import syntax we currently support is import mongoose from 'mongoose'; and in general there really isn't a way for us to support import * as mongoose with the way our code is currently structured. Sorry for the trouble.

@deckyfx
Copy link
Author

deckyfx commented Oct 3, 2018

import mongoose from 'mongoose';
raise error mongoose has no default export

while
import * as mongoose from 'mongoose';
still work at the following versions

"mongoose": "^5.2.2",
"@types/mongoose": "^5.2.0",

@vkarpov15
Copy link
Collaborator

@deckyfx what transpiler are you using? I haven't seen the 'no default export' error you mentioned even though we support building with webpack. If you're using typescript, you might try the suggestion from this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants