blob: 9f52a1d209b80870c5845c9164a08b6e6658b4f3 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package nosql
import (
wire "v.io/syncbase/v23/services/syncbase/nosql"
"v.io/v23/context"
)
// NewSchema creates a new Schema object.
func NewSchema(metadata wire.SchemaMetadata, upgrader SchemaUpgrader) *Schema {
return &Schema{
Metadata: metadata,
Upgrader: upgrader,
}
}
//////////////////////////////////////////
// Implementation of SchemaManager (Not part of public client API)
type schemaManagerImpl struct {
dbName string
c wire.DatabaseClientMethods
}
func newSchemaManager(dbName string) schemaManagerImpl {
return schemaManagerImpl{
dbName: dbName,
c: wire.DatabaseClient(dbName),
}
}
// GetSchemaMetadata retrieves the schema metadata for the database it is
// derived from.
func (sm *schemaManagerImpl) getSchemaMetadata(ctx *context.T) (wire.SchemaMetadata, error) {
return sm.c.GetSchemaMetadata(ctx)
}
// SetSchemaMetadata stores the schema metadata for the database it is
// derived from.
func (sm *schemaManagerImpl) setSchemaMetadata(ctx *context.T, metadata wire.SchemaMetadata) error {
return sm.c.SetSchemaMetadata(ctx, metadata)
}