Skip to content

RoleMapping.findOrCreate always create new mapping in lp 3.x #3263

Description

@alemhnan

I am migrating from LoopBack 2 to 3.x. I have this piece of code in a boot script:

const rm = { 
  principalType: RM.USER, 
  principalId: userId.toString(),
  roleId: roleId.toString(),
};
return RoleMapping.findOrCreate({ where: rm }, rm);

In Loopback 2.x it was behaving as expected, in 3.0 the findOrCreate always create a new instance.

I tried to update also just the loopback-datasource-juggler using version 2 but the problem apparently is in loopback 3.0 and not the juggler.

Additional information

darwin x64 6.10.0
Node v6.10.0
├── loopback@3.4.0
├── loopback-boot@2.23.0
├── loopback-component-explorer@4.1.1
├── loopback-component-model-diagram@0.3.0
├── loopback-component-storage@3.1.0
├── loopback-connector-mongodb@3.0.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions