Socket
Socket
Sign inDemoInstall

@zeit/cosmosdb-query

Package Overview
Dependencies
Maintainers
15
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zeit/cosmosdb-query - npm Package Compare versions

Comparing version 0.0.9 to 0.1.0

10

lib/executor.js

@@ -10,4 +10,9 @@ //

code,
parameters
}
parameters,
udf
}
) => {

@@ -28,4 +33,5 @@ // eslint-disable-next-line no-new-func

helpers,
udf,
params
);
};

13

lib/index.js

@@ -32,3 +32,12 @@ //

exec(coll , parameters ) {
exec(
coll ,
{
parameters,
udf
}
= {}
) {
const { code } = this;

@@ -39,3 +48,3 @@ if (!code) {

return execute(coll, { code, parameters });
return execute(coll, { code, parameters, udf });
}

@@ -42,0 +51,0 @@

@@ -636,2 +636,7 @@ //

},
// udf
{
type: "Identifier",
name: "udf"
},
// parameters

@@ -638,0 +643,0 @@ {

{
"name": "@zeit/cosmosdb-query",
"version": "0.0.9",
"version": "0.1.0",
"license": "UNLICENSED",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -6,22 +6,72 @@ # cosmosdb-query

```js
const query = require('@zeit/cosmosdb-query')
const query = require("@zeit/cosmosdb-query")
const collection = [
{ id: 'foo' },
{ id: 'bar' }
{ id: "foo" },
{ id: "bar" }
]
const docs = query('SELECT * FROM c WHERE c.id = @id')
.exec(collection, [{ name: '@id', value: 'foo' }])
console.log(docs) // [ { id: 'foo' } ]
const docs = query("SELECT * FROM c WHERE c.id = @id")
.exec(collection, {
parameters: [{ name: "@id", value: "foo" }]
})
console.log(docs) // [ { id: "foo" } ]
```
q = query('SELECT * FROM c WHERE c.id = 1')
if (!q.containsPartitionKeys(['/key'])) {
throw new Error('query doesn\'t contain partition keys')
### query(sql)
- `sql` <string>
- Returns: <Query>
```js
const q = query("SELECT * FROM c")
```
## Class: Query
### q.exec(collection[, options])
- `collection` <Object[]> | <null>
- `options` <Object>
- `parameters` <Object[]> The parameters to pass to query
- `udf` <Object>
- Returns: <Object[]>
Executes query for `collection`.
```js
query(`SELECT VALUE udf.REGEX_MATCH("foobar", ".*bar")`).exec(null, {
udf: {
REGEX_MATCH(input, pattern) {
return input.match(pattern) !== null
}
}
})
```
### q.containsPartitionKeys(keys)
- `keys` <string[]>
- Returns: <boolean>
Determines whether query may contain partition keys.
```js
const q = query("SELECT * FROM c WHERE c.id = 1")
if (!q.containsPartitionKeys(["/key"])) {
throw new Error("query doesn't contain partition keys")
}
```
### q.ast
- <Object>
The AST object of query.
## TODO
- Spatial functions
- User-defined functions
- Support spatial functions
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc