100 lines
1.4 KiB
Go
100 lines
1.4 KiB
Go
package mdbc
|
|
|
|
import (
|
|
"google.golang.org/protobuf/proto"
|
|
"reflect"
|
|
)
|
|
|
|
// model props for protobuf Message
|
|
type model struct {
|
|
Type proto.Message // model prototype
|
|
modelKind reflect.Type // model low level type
|
|
modelName string // model struct name
|
|
tableName string // model mapping table name
|
|
}
|
|
|
|
// Scope export operation for user
|
|
type scope struct {
|
|
*model
|
|
*mdbc
|
|
}
|
|
|
|
type Collection interface {
|
|
Aggregate()
|
|
BulkWrite()
|
|
Clone()
|
|
Count() *countScope
|
|
Delete() *deleteScope
|
|
Find() *findScope
|
|
Drop() *dropScope
|
|
Indexes() *indexesScope
|
|
Insert() *insertScope
|
|
Update() *updateScope
|
|
Watch()
|
|
}
|
|
|
|
// Aggregate aggregate operate for mongo
|
|
func (s *scope) Aggregate() {
|
|
|
|
}
|
|
|
|
func (s *scope) BulkWrite() {
|
|
|
|
}
|
|
|
|
func (s *scope) Clone() {
|
|
|
|
}
|
|
|
|
func (s *scope) Count() *countScope {
|
|
return &countScope{
|
|
scope: s,
|
|
mdbc: s.mdbc,
|
|
}
|
|
}
|
|
|
|
func (s *scope) Delete() *deleteScope {
|
|
return &deleteScope{
|
|
scope: s,
|
|
mdbc: s.mdbc,
|
|
}
|
|
}
|
|
|
|
func (s *scope) Find() *findScope {
|
|
return &findScope{
|
|
scope: s,
|
|
mdbc: s.mdbc,
|
|
}
|
|
}
|
|
|
|
func (s *scope) Drop() *dropScope {
|
|
return &dropScope{
|
|
scope: s,
|
|
mdbc: s.mdbc,
|
|
}
|
|
}
|
|
|
|
func (s *scope) Indexes() *indexesScope {
|
|
return &indexesScope{
|
|
scope: s,
|
|
mdbc: s.mdbc,
|
|
}
|
|
}
|
|
|
|
func (s *scope) Insert() *insertScope {
|
|
return &insertScope{
|
|
scope: s,
|
|
mdbc: s.mdbc,
|
|
}
|
|
}
|
|
|
|
func (s *scope) Update() *updateScope {
|
|
return &updateScope{
|
|
scope: s,
|
|
mdbc: s.mdbc,
|
|
}
|
|
}
|
|
func (s *scope) Watch() {
|
|
|
|
}
|