package mongodbAPI import "encoding/json" type ( // FindOneQuery represents the type used to make a query against the database // and return a single value back. // swagger:model FindOneQuery struct { Query interface{} `json:"query"` Projection []string `json:"projection,omitempty"` Output string `json:"output,omitempty"` BsonID bool `json:"bson_id,omitempty"` } // FindQuery represents the type used to make a query against the MongoAPI // swagger:model FindQuery struct { // Dict type interface to query // required: true Query interface{} `json:"query"` // List of items to filter. Show only these items Projection []string `json:"projection,omitempty"` Sort Sort `json:"sort,omitempty"` Skip int `json:"skip,omitempty"` Limit int `json:"limit,omitempty"` Output string `json:"output,omitempty"` // Use if querying by _id and the id is of type BSON BsonID bool `json:"bson_id,omitempty"` } ) // Find method takes a mongodbAPI client as a pointer receiver and // calls the mongo using the /Find URI func (d *Client) Find(f *FindQuery, table string) ([]byte, error) { payload, err := json.Marshal(f) if err != nil { return nil, err } return d.post(payload, table+"/Find") } // FindOne method takes a mongodbAPI client as a pointer receiver and // calls the mongo using the /FindOne URI func (d *Client) FindOne(f *FindOneQuery, table string) ([]byte, error) { payload, err := json.Marshal(f) if err != nil { return nil, err } return d.post(payload, table+"/FindOne") }