Skip to content

[TypeScript] Error generate different table indexes #4622

@n0ar3

Description

@n0ar3

Server module table indexes using accessor

export const player = table(
  {
    name: "player", public: true,
    indexes: [{accessor: "playerRoom", algorithm: "btree", columns: ["roomId"]}]
  },
  {
    identity: t.identity().primaryKey(),
    roomId: t.u64(),
    name: t.string(),
    score: t.u32(),
    color: t.string(),
    joinedAt: t.timestamp()
  }
)

then after I generate using CLI the result indexes change to name

  room: __table({
    name: 'room',
    indexes: [
      { name: 'code', algorithm: 'btree', columns: [
        'code',
      ] },
      { name: 'id', algorithm: 'btree', columns: [
        'id',
      ] },
    ],
    constraints: [
      { name: 'room_code_key', constraint: 'unique', columns: ['code'] },
      { name: 'room_id_key', constraint: 'unique', columns: ['id'] },
    ],
  }, RoomRow),

causing the error on the client side

Uncaught (in promise) TypeError: Index 'id' on table 'cell_state' must define a non-empty 'accessor'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions