Tuesday 6 June 2017

node mongoose how to get a full list of schemas (documents and subdocuments )

I know that I can get a full list of models using modelNames() :

console.log('MODELS: %j', mongoose.modelNames());

Is there any way to get a full list of schemas

i.e. with the following User model

const Role = new mongoose.Schema({ .... });
const Permission = new mongoose.Schema({ .... });

const UserSchema = new mongoose.Schema({
  username: { ...  },
  roles: [Role],
  permissions: [Permission]
});

I would like to get an Array object like ['Role', 'Permission']

thanks for feedback



via erwin

No comments:

Post a Comment