| | | 1 | | using Elsa.Persistence.VNext.Contracts; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Persistence.VNext.Document; |
| | | 4 | | |
| | | 5 | | public class DocumentDatabasePlanner : IPersistenceSchemaPlanner<DocumentDatabasePlan> |
| | | 6 | | { |
| | | 7 | | public DocumentDatabasePlan Plan(PersistenceSchema schema) |
| | | 8 | | { |
| | 18 | 9 | | var collections = schema.StorageUnits.Select(PlanCollection).ToList(); |
| | 18 | 10 | | return new DocumentDatabasePlan(collections); |
| | | 11 | | } |
| | | 12 | | |
| | | 13 | | private static DocumentCollection PlanCollection(PersistenceStorageUnit storageUnit) |
| | | 14 | | { |
| | 24 | 15 | | var fields = storageUnit.Fields |
| | 156 | 16 | | .Select(field => new DocumentField(field.Name, field.Type, field.IsNullable)) |
| | 24 | 17 | | .ToList(); |
| | 24 | 18 | | var indexes = storageUnit.Indexes |
| | 66 | 19 | | .Select(index => new DocumentIndex(index.Name, storageUnit.Name, storageUnit.Namespace, index.Columns, index |
| | 24 | 20 | | .ToList(); |
| | 24 | 21 | | var keyFields = storageUnit.Key?.Columns ?? []; |
| | | 22 | | |
| | 24 | 23 | | return new DocumentCollection(storageUnit.Name, storageUnit.Namespace, fields, keyFields, indexes); |
| | | 24 | | } |
| | | 25 | | } |