Documentation ¶
Overview ¶
* Copyright 2020 Mark Lakes * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- func SetErrorMap(mongoErrStr, normalizedErrStr string)
- func SetKeyFieldName(keyName string)
- type Client
- func (clt *Client) Create(entity, keyValue string, valueEntry map[string]interface{}) (*map[string]interface{}, error)
- func (clt *Client) Delete(entity, id string) error
- func (clt *Client) Find(entity, field, value string) ([]interface{}, error)
- func (clt *Client) Read(entity, keyValue string) (*map[string]interface{}, error)
- func (clt *Client) ReadAll(entity string) ([]interface{}, error)
- func (clt *Client) Update(entity, id string, valueEntry map[string]interface{}) error
- type ClientOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetErrorMap ¶
func SetErrorMap(mongoErrStr, normalizedErrStr string)
SetErrorMap allows user to create normalized errors for their apps to handle without exposing underlying mongodb specific errors
func SetKeyFieldName ¶
func SetKeyFieldName(keyName string)
SetKeyFieldName allows user to over-ride the default name of the "key" field
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client used for the mongo client api
func NewClient ¶
func NewClient(coptions ...ClientOption) (*Client, error)
NewClient creates a new mongo client using the specified options
func (*Client) Create ¶
func (clt *Client) Create(entity, keyValue string, valueEntry map[string]interface{}) (*map[string]interface{}, error)
Create or insert a new entry into the collection entity
func (*Client) Find ¶
Find entry for specified entity where value matches the value in the field If field and value are empty, then return all entries for the specified entity
type ClientOption ¶
type ClientOption struct {
// contains filtered or unexported fields
}
ClientOption specifies an option for connecting to a mongodb server
func ClientAuthDbName ¶
func ClientAuthDbName(name string) ClientOption
ClientAuthDbName specifies the name of auth database containing the user when connecting to the server Optional: This was required on Ubuntu but not on MAC
func ClientCommTimeout ¶
func ClientCommTimeout(timeOut int) ClientOption
ClientCommTimeout specifies the timeout for communicating to the mongo server
func ClientDbName ¶
func ClientDbName(name string) ClientOption
ClientDbName specifies the name of database to write or read data from
func ClientDbPasswd ¶
func ClientDbPasswd(passwd string) ClientOption
ClientDbPasswd specifies the password for user to access the database
func ClientDbUser ¶
func ClientDbUser(user string) ClientOption
ClientDbUser specifies the user inwhich to access the database
func ClientHostPort ¶
func ClientHostPort(hostPort string) ClientOption
ClientHostPort specifies the host and port inwhich to access the database ex: "127.0.0.1:27017" Supports sharded db - can call multiple times host+ports