Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self reference on model not being "expanded" #3804

Closed
emhagman opened this issue May 26, 2015 · 0 comments
Closed

Self reference on model not being "expanded" #3804

emhagman opened this issue May 26, 2015 · 0 comments

Comments

@emhagman
Copy link

I have a model defined as:

sequelize.define('referral', {
        status: {
            type: DataTypes.ENUM('OPENED', 'INTERESTED'),
            allowNull: false,
            defaultValue: null
        },
        maxReferrals: {
            field: 'max_referrals',
            type: DataTypes.INTEGER,
            allowNull: false,
            defaultValue: null
        },
        properties: {
            type: DataTypes.JSON,
            allowNull: true,
            defaultValue: null
        },
        reward: {
            type: DataTypes.NUMERIC,
            allowNull: true,
            defaultValue: null
        },
        broken: {
            type: DataTypes.BOOLEAN,
            allowNull: false,
            defaultValue: false
        }
    }, {tableName: 'referral', underscored: true, underscoredAll: true});

Later on:
Referral.belongsTo(Referral, {foreignKey: 'referral_id', as: 'referral', constraints: false});

Basically, every referral has referral_id that references another referral. I can see the referral_id field in my result, but I am missing the expanded referral object that the referral references.

I am calling .findAll({ includes: [{all: true, nested: true}]}) so I believe that data should be there. Any thoughts?

All of the other expands work.

IrfanBaqui pushed a commit to IrfanBaqui/sequelize that referenced this issue Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant