I am trying to create an application for sports event management system using MEAN.io
Since it uses the modular approach, there are different packages that comes in skeleton application like system
, users
, access
. What i want to do is make a new package called players
and it should extend the users package. The players schema would contain extra fields section
and teams
.So how do I extend the User Schema of users
package in players
package?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- How to reimport module with ES6 import
- Why is `node.js` dying when called from inside pyt
- How to verify laravel passport api token in node /
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- MongoError: cannot infer query fields to set, path
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
You can make your players package be dependent on users.
Players.register(function(app, auth, users, database) {...});
You now have access to the database and can load the user schema with
var userModel = database.connection.model('User');
and you can use the schema.add function to extend the schema
userModel.schema.add({ scrore: 'string'});
This should add the score field to the user model
I think this might work for you. But I was told from a member of mongoose team that schema.add only works before compiling the model. See this link for more info about schema add http://mongoosejs.com/docs/api.html#schema_Schema-add