Beispiel #1
0
        public async Task Upgrade()
        {
            IReadOnlyCollection <string> existingCollections = await _db.GetCollectionNamesAsync();

            if (!existingCollections.Contains(CollectionName))
            {
                await _db.CreateCollectionAsync(CollectionName);

                await _db.GetCollection <RecordedEvent>(CollectionName).CreateIndex("StreamID");
            }

            string[] missingCollections = _streams
                                          .Select(s => GetStreamInfoName(s))
                                          .Except(existingCollections)
                                          .ToArray();

            await Task.WhenAll(missingCollections.Select(x => _db.CreateCollectionAsync(x)));
        }