【问题标题】:How can I extend the users collection with Astronomy and accounts-ui?如何使用 Astronomy 和 accounts-ui 扩展用户集合?
【发布时间】:2019-01-11 19:52:48
【问题描述】:

我需要能够扩展 account-ui 默认创建的用户集合。

import { Class } from 'meteor/jagi:astronomy';
import { Behavior } from 'meteor/jagi:astronomy-softremove-behavior';

/**
 * @class User
 */
const User = Class.create ({
    name: 'User',
    collection: Meteor.Users,
    secured: false,
    fields: {
        emails: {
            type: Email,
            optional: true
        }
    },
    behaviors: {
        softremove: {
            removedFieldName: 'removed',
            hasRemovedAtField: true,
            removedAtFieldName: 'removedAt'
        },
        timestamp: {
            hasCreatedField: true,
            createdFieldName: 'createdAt',
            hasUpdatedField: true,
            updatedFieldName: 'updatedAt'
        }
    }
});

export default User;

我不想使用 Meteor.user.(),只喜欢使用 User 类。

【问题讨论】:

    标签: meteor meteor-accounts astronomy


    【解决方案1】:

    欢迎来到 Stack Overflow。

    Meteor 中的用户集合很特别。在 Mongo 的引擎盖下,它是一个常规集合。

    出于安全原因,您不能像常规收藏一样使用用户收藏,例如您可以更新自己的用户记录,但不能浏览和编辑其他用户记录。

    我的建议是为您的用户个人资料信息创建一个单独的集合。这不是一个完美的解决方案,但最好将用户集合置于 Meteor 帐户包的控制之下。

    可以扩展集合以存储一些配置文件类型的数据元素,但即使这样也有一些问题,因为当更新用户记录时,跟踪器会运行,并且您的 UI 将刷新(如果刷新不是预期的)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-10
      • 2011-03-04
      • 1970-01-01
      • 1970-01-01
      • 2014-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多