types

package
v0.19.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// All is used when all the records needs to be worked on
	All string = "all"

	// One is used when oly a single record needs to be worked on
	One string = "one"

	// Read is used to Read documents
	Read string = "read"

	Aggregate string = "aggr"

	// Upsert is used to upsert documents
	Batch string = "batch"

	// Count is used to count the number of documents returned
	Count string = "count"

	// Distinct is used to get the distinct values
	Distinct string = "distinct"

	// Upsert is used to upsert documents
	Upsert string = "upsert"

	// Delete is used to delete documents
	Delete string = "delete"

	// Update is used to update documents
	Update string = "update"

	// Create is used to create documents
	Create string = "create"

	// PreparedQueries is used execute a particular Prepared Query
	PreparedQueries string = "prepared-queries"
)
View Source
const (
	// TypeRealtimeSubscribe is the request type for live query subscription
	TypeRealtimeSubscribe string = "realtime-subscribe"

	// TypeRealtimeUnsubscribe is the request type for live query subscription
	TypeRealtimeUnsubscribe string = "realtime-unsubscribe"

	// TypeRealtimeFeed is the response type for realtime feed
	TypeRealtimeFeed string = "realtime-feed"
)
View Source
const (
	// RealtimeInsert is for create operations
	RealtimeInsert string = "insert"

	// RealtimeUpdate is for update operations
	RealtimeUpdate string = "update"

	// RealtimeDelete is for delete operations
	RealtimeDelete string = "delete"

	// RealtimeInitial is for initial operations
	RealtimeInitial string = "initial"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateRequest

type AggregateRequest struct {
	Pipeline  interface{} `json:"pipe"`
	Operation string      `json:"op"`
}

AggregateRequest is the http body received for an aggregate request

type AllRequest

type AllRequest struct {
	Col       string      `json:"col"`
	Document  interface{} `json:"doc"`
	Operation string      `json:"op"`
	Find      interface{} `json:"find"`
	Update    interface{} `json:"update"`
	Type      string      `json:"type"`
}

AllRequest is a union of parameters required in the various requests

type BatchRequest

type BatchRequest struct {
	Requests []AllRequest `json:"reqs"`
}

BatchRequest is the http body for a batch request

type ColStore

type ColStore map[string]IdStore

type CreateRequest

type CreateRequest struct {
	Document  interface{} `json:"doc"`
	Operation string      `json:"op"`
}

CreateRequest is the http body received for a create request

type DbStore

type DbStore map[string]ColStore

type DeleteRequest

type DeleteRequest struct {
	Find      map[string]interface{} `json:"find"`
	Operation string                 `json:"op"`
}

DeleteRequest is the http body received for a delete request

type DocumentSnapshot

type DocumentSnapshot struct {
	// contains filtered or unexported fields
}

DocumentSnapshot contains the data and meta info of a single document

func (*DocumentSnapshot) Unmarshal

func (s *DocumentSnapshot) Unmarshal(vPtr interface{}) error

Unmarshal parses the document and stores the value into vPtr

type FunctionsPayload

type FunctionsPayload struct {
	ID      string                 `json:"id"`
	Auth    map[string]interface{} `json:"auth"`
	Params  interface{}            `json:"params"`
	Service string                 `json:"service"`
	Func    string                 `json:"func"`
	Error   string                 `json:"error"`
}

FunctionsPayload is the struct transmitted via the broker

type IdStore

type IdStore map[string]*Store

type LiveQueryOptions

type LiveQueryOptions struct {
	ChangesOnly bool
	SkipInitial bool `json:"skipInitial"`
}

LiveQueryOptions is used to set the options for the live query

type M

type M map[string]interface{}

M is a type representing a map

func And

func And(conds ...M) M

And is a function to "and" multiple conditions together

func Cond

func Cond(f1, eval string, f2 interface{}) M

Cond is a function to write a condition

func GenerateFind

func GenerateFind(condition M) M

GenerateFind generates a Mongo db find clause from the provided condition

func Or

func Or(conds ...M) M

Or is a function to "or" multiple conditions together

type Meta

type Meta struct {
	DbType, Col, ID string
	Token           string
	Project         string
	Operation       string
}

type PreparedQueryRequest added in v0.18.0

type PreparedQueryRequest struct {
	Params map[string]interface{} `json:"params"`
}

PreparedQueryRequest is the http body received for a PreparedQuery request

type ProfileParams

type ProfileParams struct {
	Email    string
	Name     string
	Password string
}

A struct to hold the new values for EditProfile

type ReadOptions

type ReadOptions struct {
	Select   map[string]int32 `json:"select"`
	Sort     []string         `json:"sort"`
	Skip     *int64           `json:"skip"`
	Limit    *int64           `json:"limit"`
	Distinct *string          `json:"distinct"`
}

ReadOptions is the options required for a read request

type ReadRequest

type ReadRequest struct {
	GroupBy   []interface{}          `json:"group"`
	Aggregate map[string][]string    `json:"aggregate"`
	Find      map[string]interface{} `json:"find"`
	Operation string                 `json:"op"`
	Options   *ReadOptions           `json:"options"`
}

ReadRequest is the http body received for a read request

type RealtimeParams

type RealtimeParams struct {
	Find M
}

type RealtimeRequest

type RealtimeRequest struct {
	Token   string                 `json:"token"`
	DBType  string                 `json:"dbType"`
	Project string                 `json:"project"`
	Group   string                 `json:"group"` // Group is the collection name
	Type    string                 `json:"type"`  // Can either be subscribe or unsubscribe
	ID      string                 `json:"id"`    // id is the query id
	Where   map[string]interface{} `json:"where"`
	Options *LiveQueryOptions      `json:"options"`
}

RealtimeRequest is the object sent for realtime requests

type Response

type Response struct {
	Status int
	Data   M
	Error  string
}

Response is the object recieved from the server. Status is the status code received from the server. Data is either a map[string]interface{} or

func (*Response) GetError

func (res *Response) GetError() error

GetError returns the error message receieved from the server

func (*Response) GetStatus

func (res *Response) GetStatus() int

GetStatus returns the response status

func (*Response) Raw

func (res *Response) Raw() map[string]interface{}

Raw returns the raw map

func (*Response) Unmarshal

func (res *Response) Unmarshal(v interface{}) error

Unmarshal parses the response data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an error.

type ServiceRequest

type ServiceRequest struct {
	Params  interface{} `json:"params"`
	Timeout int         `json:"timeout"`
}

ServiceRequest is the api call request

type SnapshotData

type SnapshotData struct {
	Find      map[string]interface{}
	Time      int64
	Payload   interface{}
	IsDeleted bool
}

type Storage

type Storage struct {
	Id        string
	Time      int64
	Payload   []byte
	IsDeleted bool
}

Storage is a struct to store the Live Query Data (For Internal Use Only)

type Store

type Store struct {
	QueryOptions LiveQueryOptions
	Snapshot     []*SnapshotData
	C            chan *SubscriptionEvent
	Find         interface{}
	Options      interface{}
	Unsubscribe  func()
}

type SubscriptionEvent

type SubscriptionEvent struct {
	// contains filtered or unexported fields
}

func NewSubscriptionEvent

func NewSubscriptionEvent(evType string, doc interface{}, find map[string]interface{}, err error) *SubscriptionEvent

func (*SubscriptionEvent) Err

func (s *SubscriptionEvent) Err() error

func (*SubscriptionEvent) Find

func (s *SubscriptionEvent) Find() map[string]interface{}

func (*SubscriptionEvent) Type

func (s *SubscriptionEvent) Type() string

func (*SubscriptionEvent) Unmarshal

func (s *SubscriptionEvent) Unmarshal(vPtr interface{}) error

type SubscriptionObject

type SubscriptionObject struct {
	// contains filtered or unexported fields
}

func LiveQuerySubscriptionInit

func LiveQuerySubscriptionInit(store *Store) *SubscriptionObject

func (*SubscriptionObject) C

func (*SubscriptionObject) GetSnapshot

func (s *SubscriptionObject) GetSnapshot() []DocumentSnapshot

func (*SubscriptionObject) Unsubscribe

func (s *SubscriptionObject) Unsubscribe()

Unsubscribe

type UpdateRequest

type UpdateRequest struct {
	Find      map[string]interface{} `json:"find"`
	Operation string                 `json:"op"`
	Update    map[string]interface{} `json:"update"`
}

UpdateRequest is the http body received for an update request

type WebsocketMessage

type WebsocketMessage struct {
	Type string      `json:"type"`
	Data interface{} `json:"data"`
	ID   string      `json:"id"` // the request id
}

WebsocketMessage is the body for a websocket request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL