How to use the @zeit/cosmosdb-query function in @zeit/cosmosdb-query

To help you get started, we’ve selected a few @zeit/cosmosdb-query examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeit / cosmosdb-server / src / handler / query-documents.ts View on Github external
readItems(req, res, "Documents", async ({ continuation, maxItemCount }) => {
    const body = await json(req);
    if (!body.query) {
      res.statusCode = 400;
      return { Message: "missing query" };
    }

    const collection = account.database(dbId).collection(collId);

    if (req.headers["x-ms-documentdb-query-enablecrosspartition"] !== "true") {
      const { partitionKey }: { partitionKey?: any } = collection.read() || {};
      const paths = (partitionKey || {}).paths || [];
      if (paths.length && !query(body.query).containsPartitionKeys(paths)) {
        res.statusCode = 400;
        return { Message: "missing partition keys" };
      }
    }

    return collection.documents.query(body, { continuation, maxItemCount });
  });
github zeit / cosmosdb-server / src / account / items.ts View on Github external
read({
    maxItemCount,
    continuation
  }: {
    maxItemCount?: number | null;
    continuation?: {
      token: string;
    } | null;
  } = {}) {
    if (!this._parent.read()) return null;

    const data = [...this._data.values()].map(item => item.read());
    return query("SELECT * FROM c").exec(data, { maxItemCount, continuation });
  }
github zeit / cosmosdb-server / src / account / items.ts View on Github external
},
    {
      maxItemCount,
      continuation
    }: {
      maxItemCount?: number | null;
      continuation?: {
        token: string;
      } | null;
    }
  ) {
    if (!this._parent.read()) return null;

    const data = [...this._data.values()].map(item => item.read());
    const udf = this._userDefinedFunctions();
    return query(params.query).exec(data, {
      parameters: params.parameters,
      udf,
      maxItemCount,
      continuation
    });
  }

@zeit/cosmosdb-query

A SQL parser and executer for Cosmos DB

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis

Popular @zeit/cosmosdb-query functions

Similar packages