TinyBase logoTinyBase β

CanWriteCell

The CanWriteCell type describes a function that decides whether a client may write a given Cell on a path of a WsServer.

(
  pathId: Id,
  tableId: Id,
  rowId: Id,
  cellId: Id,
  cell: CellOrUndefined,
  context: {[key: string]: any} | undefined,
): boolean
TypeDescription
pathIdId

The Id of the path.

tableIdId

The Id of the Table.

rowIdId

The Id of the Row.

cellIdId

The Id of the Cell.

cellCellOrUndefined

The new value of the Cell, or undefined if it is being deleted.

context{[key: string]: any} | undefined

The context from the client's ClientAccess.

returnsboolean

Whether the client may write the Cell.

It is called for each Cell in the changes that a writable client sends to the server, including deletions, where the cell parameter is undefined. It must be synchronous. Cells for which it returns false are neither merged into the path's MergeableStore nor relayed to other clients.

If the rejected change was newer than the server's own version of that Cell, and different from it, the server sends that client alone its own version (or a deletion, if it has none), stamped just after the rejected change. The client is brought back into line with the server, rather than silently diverging from it, and nothing changes on the server or for any other client.

This function decides only about Cells. Unless you also provide a CanWriteValue function, every writable client may write any Value. And unless you provide an Authorize function, every client is admitted as writable, with an undefined context.

Since

v10.1.0