ReadSchema - Reads a new schema from repository
(_ context.Context, tenantID, version string)
| 30 | |
| 31 | // ReadSchema - Reads a new schema from repository |
| 32 | func (r *SchemaReader) ReadSchema(_ context.Context, tenantID, version string) (sch *base.SchemaDefinition, err error) { |
| 33 | txn := r.database.DB.Txn(false) |
| 34 | defer txn.Abort() |
| 35 | var it memdb.ResultIterator |
| 36 | it, err = txn.Get(constants.SchemaDefinitionsTable, "version", tenantID, version) // Query schema by version |
| 37 | if err != nil { |
| 38 | return sch, errors.New(base.ErrorCode_ERROR_CODE_EXECUTION.String()) |
| 39 | } |
| 40 | |
| 41 | var definitions []string |
| 42 | for obj := it.Next(); obj != nil; obj = it.Next() { |
| 43 | definitions = append(definitions, obj.(storage.SchemaDefinition).Serialized()) |
| 44 | } |
| 45 | |
| 46 | sch, err = schema.NewSchemaFromStringDefinitions(false, definitions...) |
| 47 | if err != nil { |
| 48 | return nil, err |
| 49 | } |
| 50 | |
| 51 | return sch, nil |
| 52 | } |
| 53 | |
| 54 | // ReadSchemaString returns the schema definition for a specific tenant and version as a string. |
| 55 | func (r *SchemaReader) ReadSchemaString(_ context.Context, tenantID, version string) (definitions []string, err error) { |
nothing calls this directly
no test coverage detected