deploySchema function

Future<void> deploySchema({
  1. required RoomClient room,
  2. required MeshSchema schema,
  3. required String name,
  4. bool overwrite = true,
})

Deploy schema to the room’s storage.

Implementation

Future<void> deploySchema({required RoomClient room, required MeshSchema schema, required String name, bool overwrite = true}) async {
  _validateSchemaName(name);

  final handle = await room.storage.open('.schemas/$name.json', overwrite: overwrite);

  // Convert schema to JSON, then to bytes.
  final data = utf8.encode(jsonEncode(schema.toJson()));

  await room.storage.write(handle, data);
  await room.storage.close(handle);
}