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

refactor(database): columns -> cells #1925

Merged
merged 10 commits into from
Apr 3, 2023
Merged

refactor(database): columns -> cells #1925

merged 10 commits into from
Apr 3, 2023

Conversation

doodlewind
Copy link
Member

@doodlewind doodlewind commented Apr 2, 2023

Lacking the concept of cell leads to serious ambiguity and incorrect variable naming in current database implementation. So the decision is to rename the ext:columns nested map to ext:cells, which is indeed a two-dimensional map (rowId + columnId) that contains database cells.

Before (nuanced "column" concept):

  getColumn(model: BaseBlockModel, schema: ColumnSchema): BlockColumn | null {
    const yColumns = this.yColumns.get(model.id);
    const yColumnMap = (yColumns?.get(schema.id) as Y.Map<unknown>) ?? null;
    if (!yColumnMap) return null;

    return {
      columnId: yColumnMap.get('columnId') as string,
      value: yColumnMap.get('value') as unknown,
    };
  }

After (yCells -> yRow -> yCell):

  getCell(model: BaseBlockModel, schema: ColumnSchema): Cell | null {
    const yRow = this.yCells.get(model.id);
    const yCell = (yRow?.get(schema.id) as Y.Map<unknown>) ?? null;
    if (!yCell) return null;

    return {
      columnId: yCell.get('columnId') as string,
      value: yCell.get('value') as unknown,
    };
  }

For future kanban view, we can still group them based on different values on the same column (columnSchema).

After this is landed, I would continue renaming columnSchema to column, which reflects the table structure better.

@codesandbox
Copy link

codesandbox bot commented Apr 2, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@vercel
Copy link

vercel bot commented Apr 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocksuite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2023 8:37am
blocksuite-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2023 8:37am
blocksuite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2023 8:37am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Contains breaking change that must be addressed
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

1 participant