Skip to content

autoFetch does't work when cache is true for a model #339

Description

@mkMoSs
var Reward = db.define('reward', {
        description: { type: 'text'},
        value: { type: 'money'}
    },
    { autoSave: true, autoFetch: true, autoFetchLimit: 3 }
);
var RewardType = db.define('rewardtype', {
        title: { type: 'text', size: 100}
    },
    { autoSave: true }
);

Reward.hasOne('type', RewardType, {reverse: 'rewards' });

In this example Reward has one to many relationships with RewardType when cache is left default (true) Reward.get(...) returns undefined for property "type" while type_id has a value.

When setting cache: false to both models, the 'type' property gets populated as expected using autofetch.

Is this a bug or is it normal behaviour? Spend hours trying to figure why autoFetch wasn't working...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions