NewMemDB creates a new MemDB with the given schema.
(schema *DBSchema)
| 37 | |
| 38 | // NewMemDB creates a new MemDB with the given schema. |
| 39 | func NewMemDB(schema *DBSchema) (*MemDB, error) { |
| 40 | // Validate the schema |
| 41 | if err := schema.Validate(); err != nil { |
| 42 | return nil, err |
| 43 | } |
| 44 | |
| 45 | // Create the MemDB |
| 46 | db := &MemDB{ |
| 47 | schema: schema, |
| 48 | root: unsafe.Pointer(iradix.New()), |
| 49 | primary: true, |
| 50 | } |
| 51 | if err := db.initialize(); err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | |
| 55 | return db, nil |
| 56 | } |
| 57 | |
| 58 | // DBSchema returns schema in use for introspection. |
| 59 | // |
searching dependent graphs…