Skip to content

LB3 model import: handle ObjectID type for MongoDB #3814

@bajtos

Description

@bajtos

In LB3, the type of the primary key is determined by the connector. The MongoDB connector defines the type as ObjectID, using a class provided by MongoDB (bson module).

Conceptually:

{
  "name": "Product",
  "properties": {
    "id": {
      "id": true,
       "generated": true,
       "type": ObjectID
    }
  }
}

In LB4, we treat ObjectID values differently:

  • the property type is set to string
  • there is MongoDB-specific metadata to tell the connector to use ObjectID data-type for this property
@property({
  type: 'string',
  id: true,
  generated: true,
  mongodb: {dataType: 'ObjectID'},
})
id: string;

We need to improve the importer to detect ObjectID properties and convert them to LB4 format.

This task depends on #3810 LB3 model import: preserve connector-specific metadata in property definitions, because we need to define connector-specific metadata.

Acceptance criteria

  • Implement conversion of primary key (id) properties
  • Check how are foreign keys handled, implement conversion for them too if needed
  • Consider converting all properties with ObjectID type, regardless of whether they are PK/FK or not
  • if we see the property as ObjectID, we convert it to the appropriate mapping.
  • Update Importing-LB3-models.md, remove the relevant point from the list of known limitations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions