扩展mean.io的用户包 [英] Extending the users package of mean.io

查看:66
本文介绍了扩展mean.io的用户包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用MEAN.io创建体育赛事管理系统的应用程序 由于它使用模块化方法,因此骨架应用程序中提供了不同的软件包,例如systemusersaccess.我想做的是制作一个名为players的新软件包,它应该扩展users软件包.玩家模式将包含额外的字段sectionteams.那么如何在players程序包中扩展users程序包的用户模式?

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?

推荐答案

您可以使您的播放器软件包依赖于用户.

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');

,您可以使用schema.add函数扩展架构

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

我认为这可能对您有用.但是从猫鼬团队的成员那里得知,schema.add仅在编译模型之前有效.请参阅此链接,以获取有关架构添加的更多信息 http://mongoosejs.com/docs/api. html#schema_Schema-add

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

这篇关于扩展mean.io的用户包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆