createCollection static method
Future<CollectionFrameResponse>
createCollection(
- P2PStream stream, {
- required PeerId ownerPeerId,
- required String path,
- required String name,
- CollectionVisibility? visibility,
Create a new collection.
Without a visibility the server makes the collection private.
Implementation
static Future<CollectionFrameResponse> createCollection(
P2PStream stream, {
required PeerId ownerPeerId,
required String path,
required String name,
CollectionVisibility? visibility,
}) async {
try {
final requestBytes = CollectionFrame.encodeRequest(
operation: 'CREATE',
ownerPeerId: ownerPeerId,
path: path,
name: name,
visibility: visibility?.name,
);
await _writeFrameStatic(stream, requestBytes);
final responseBytes = await _readFrameStatic(stream);
return CollectionFrame.decodeResponse(responseBytes);
} catch (e, stackTrace) {
_logger.severe('Error creating collection: $e', e, stackTrace);
rethrow;
}
}