-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSchema.cs
More file actions
36 lines (31 loc) · 887 Bytes
/
Schema.cs
File metadata and controls
36 lines (31 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
namespace PowerSync.Common.DB.Schema;
using PowerSync.Common.DB.Schema.Attributes;
public class Schema
{
private readonly List<Table> _tables;
public Schema(params Table[] tables)
{
_tables = tables.ToList();
}
public Schema(params Type[] types)
{
_tables = new();
var indexes = new Dictionary<string, List<string>>();
foreach (Type type in types)
{
var parser = new AttributeParser(type);
parser.RegisterDapperTypeMap();
_tables.Add(parser.ParseTable());
}
}
internal CompiledSchema Compile()
{
Dictionary<string, CompiledTable> tableMap = new();
foreach (Table table in _tables)
{
var compiled = table.Compile();
tableMap[compiled.Name] = compiled;
}
return new CompiledSchema(tableMap);
}
}