Implementation
Future<DomainModel> createDomain({
required String name,
required String slug,
String? description,
String? iconName,
}) async {
final userId = _client.auth.currentUser?.id;
if (userId == null) {
throw StateError('Cannot create domain: user is not authenticated');
}
final response = await _client
.from('domains')
.insert({
'name': name,
'slug': slug,
'description': description,
'icon_name': iconName,
'owner_id': userId,
'visibility': 'private',
})
.select()
.single();
return DomainModel.fromJson(response);
}