Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
bitbucket.org/fonouc/couchdb-golang
A Golang library for CouchDB 2.x, inspired by CouchDB-Python.
func (d *Database) Query(fields []string, selector string, sorts []string, limit, skip, index interface{}) ([]map[string]interface{}, error)
You can query documents using a conditional selector statement in Golang. It will converts to the corresponding JSON query string.
For example:
docsQuery, err := movieDB.Query(nil, `year == 1989 && (director == "Ademir Kenovic" || director == "Dezs Garas")`, nil, nil, nil, nil)
equals to:
docsRaw, err := movieDB.QueryJSON(`
{
"selector": {
"year": 1989,
"$or": [
{ "director": "Ademir Kenovic" },
{ "director": "Dezs Garas" }
]
}
}`)
nor(condexprs...) matches if none of the conditions in condexprs match($nor). For example: nor(year == 1990, year == 1989, year == 1997) returns all documents whose year field not in 1989, 1990 and 1997.
all(field, array) matches an array value if it contains all the elements of the argument array($all). For example: all(genre, []string{"Comedy", "Short"} returns all documents whose genre field contains "Comedy" and "Short".
any(field, condexpr) matches an array field with at least one element meets the specified condition($elemMatch). For example: any(genre, genre == "Short" || genre == "Horror") returns all documents whose genre field contains "Short" or "Horror" or both.
exists(field, boolean) checks whether the field exists or not, regardless of its value($exists). For example: exists(director, false) returns all documents who does not have a director field.
typeof(field, type) checks the document field's type, valid types are "null", "boolean", "number", "string", "array", "object"($type). For example: typeof(genre, "array") returns all documents whose genre field is of array type.
in(field, array) the field must exist in the array provided($in). For example: in(director, []string{"Mike Portnoy", "Vitali Kanevsky"}) returns all documents whose director field is "Mike Portnoy" or "Vitali Kanevsky".
nin(field, array) the document field must not exist in the array provided($nin). For example: nin(year, []int{1990, 1992, 1998}) returns all documents whose year field is not in 1990, 1992 or 1998.
size(field, int) matches the length of an array field in a document($size). For example: size(genre, 2) returns all documents whose genre field is of length 2.
mod(field, divisor, remainder) matches documents where field % divisor == remainder($mod). For example: mod(year, 2, 1) returns all documents whose year field is an odd number.
regex(field, regexstr) a regular expression pattern to match against the document field. For example: regex(title, "^A") returns all documents whose title is begin with an "A".
asc(field) sorts the field in ascending order, this is the default option while desc(field) sorts the field in descending order.
go get -u -v github.com/leesper/couchdb-golang
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update unit tests as appropriate.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.