Answer the question
In order to leave comments, you need to log in
How is only the necessary one imported from the module (see inside)?
I'm new to this whole topic and don't understand the next point.
I usually import, for example, a schema from mongoose like this -> Schema = mongoose.Schema;
. That is, he pointed directly.
But in one of the lessons on YouTube, I saw this way of importing:
And it became interesting to me how, with such an import from mongoose, Schema is imported into the Schema variable ? And in model - exactly model ? Is this due to the fact that from the mongoose package itself they are exported to in that order?
PS speaking of packages... what are all those model , schema names relative to the mongoose package itself ? Package methods?
const {Schema, model, Types} = require('mongoose')
Answer the question
In order to leave comments, you need to log in
Is this due to the fact that from the mongoose package itself they are exported to in that order?
export default function() {}
import anything from 'my-module';
export const CONST_1 = 1;
export function MyFunc() {}
import { MyFunc, CONST_1 } from 'my-module';
import anything, { MyFunc, CONST_1 } from 'my-module';
Specifically, in this example, npm and modules have nothing to do with it, the usual js features:
https://developer.mozilla.org/en-US/docs/Web/JavaS...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question