Skip to content

Commit

Permalink
Feature/query option attributes (#135)
Browse files Browse the repository at this point in the history
* Attribute options for Query and Get

* BatchGet Query Option "attributes" typing

* Implementing applying attribute params to docClient

* Removing non-test files from test coverage

* Updating documentation

* Expanding parse method

* Adding further documentation

* Removing comments

* Update README.md

* Update index.d.ts
  • Loading branch information
tywalch committed Jul 5, 2022
1 parent 82a1250 commit a57344c
Show file tree
Hide file tree
Showing 37 changed files with 1,480 additions and 177 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Expand Up @@ -200,4 +200,8 @@ All notable changes to this project will be documented in this file. Breaking ch

## [1.10.2] - 2022-07-02
### Fixed
- Reorganizing type definition files into single file again to appease the frontend dependency overlords in https://electrodb.fun
- Reorganizing type definition files into single file again to appease the frontend dependency overlords in https://electrodb.fun

## [1.11.0] - 2022-07-04
### Added
- Adding support for "ProjectionExpressions" via the Query Option: `attributes` [[read more](./README#query-options)]
9 changes: 6 additions & 3 deletions README.md
Expand Up @@ -2607,9 +2607,10 @@ const formattedQueryResults = myEntity.parse(formattedQueryResults);

Parse also accepts an optional `options` object as a second argument (see the section [Query Options](#query-options) to learn more). Currently, the following query options are relevant to the `parse()` method:

Option | Default | Notes
----------------- : ------- | -----
`ignoreOwnership` | `true` | This property defaults to `true` here, unlike elsewhere in the application when it defaults to `false`. You can overwrite the default here with your own preference.
Option | Type | Default | Notes
----------------- : -------- : ------------------ | -----
ignoreOwnership | boolean | `true` | This property defaults to `true` here, unlike elsewhere in the application when it defaults to `false`. You can overwrite the default here with your own preference.
attributes | string[] | _(all attributes)_ | The `attributes` option allows you to specify a subset of attributes to return

# Building Queries
> For hands-on learners: the following example can be followed along with **and** executed on runkit: https://runkit.com/tywalch/electrodb-building-queries
Expand Down Expand Up @@ -4300,13 +4301,15 @@ By default, **ElectroDB** enables you to work with records as the names and prop
logger?: (event) => void;
listeners Array<(event) => void>;
preserveBatchOrder?: boolean;
attributes?: string[];
};
```

Option | Default | Description
------------------ | :------------------: | -----------
params | `{}` | Properties added to this object will be merged onto the params sent to the document client. Any conflicts with **ElectroDB** will favor the params specified here.
table | _(from constructor)_ | Use a different table than the one defined in the [Service Options](#service-options)
attributes | _(all attributes)_ | The `attributes` query option allows you to specify ProjectionExpression Attributes for your `get` or `query` operation. As of `1.11.0` only root attributes are allowed to be specified.
raw | `false` | Returns query results as they were returned by the docClient.
includeKeys | `false` | By default, **ElectroDB** does not return partition, sort, or global keys in its response.
pager | `"named"` | Used in with pagination (`.pages()`) calls to override ElectroDBs default behaviour to break apart `LastEvaluatedKeys` records into composite attributes. See more detail about this in the sections for [Pager Query Options](#pager-query-options).
Expand Down
1 change: 1 addition & 0 deletions examples/taskapp/bin/load.js
@@ -1,4 +1,5 @@
#!/usr/bin/env node
/* istanbul ignore file */
const path = require("path");
const taskr = require("../src/taskr");
const Loader = require("../lib/loader");
Expand Down
1 change: 1 addition & 0 deletions examples/taskapp/lib/client/index.js
@@ -1,3 +1,4 @@
/* istanbul ignore file */
const DynamoDB = require("aws-sdk/clients/dynamodb");

/**
Expand Down
1 change: 1 addition & 0 deletions examples/taskapp/lib/loader/index.js
@@ -1,3 +1,4 @@
/* istanbul ignore file */
const makeLoader = require("./mock");
const makeTabler = require("../table");
const definition = require("../table/definition.json")
Expand Down
1 change: 1 addition & 0 deletions examples/taskapp/lib/loader/mock.js
@@ -1,3 +1,4 @@
/* istanbul ignore file */
const uuid = require("uuid").v4;
const moment = require("moment");

Expand Down
1 change: 1 addition & 0 deletions examples/taskapp/src/index.js
@@ -1,3 +1,4 @@
/* istanbul ignore file */
const path = require("path");
const moment = require("moment");
const taskr = require("./taskr");
Expand Down
1 change: 1 addition & 0 deletions examples/taskapp/src/taskr.js
@@ -1,3 +1,4 @@
/* istanbul ignore file */
process.env.AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1;
const { Service } = require("../../..");
const client = require("../lib/client");
Expand Down
1 change: 1 addition & 0 deletions examples/taskapp_typescript/src/client/index.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import DynamoDB from "aws-sdk/clients/dynamodb";

/**
Expand Down
1 change: 1 addition & 0 deletions examples/taskapp_typescript/src/index.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import path from "path";
import moment from "moment";

Expand Down
1 change: 1 addition & 0 deletions examples/taskapp_typescript/src/models/employees.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import {v4 as uuid} from "uuid";
import moment from "moment";

Expand Down
1 change: 1 addition & 0 deletions examples/taskapp_typescript/src/models/offices.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
const schema = {
"model": {
"entity": "offices",
Expand Down
1 change: 1 addition & 0 deletions examples/taskapp_typescript/src/models/tasks.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
const schema = {
"model": {
"entity": "tasks",
Expand Down
1 change: 1 addition & 0 deletions examples/taskapp_typescript/src/taskr.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
process.env.AWS_NODEJS_CONNECTION_REUSE_ENABLED = "1";
import {Entity, Service} from "../../../";
import client from "./client";
Expand Down
1 change: 1 addition & 0 deletions examples/versioncontrol/database/index.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import {Service} from "../../../";

import {repositories} from "./repositories";
Expand Down
1 change: 1 addition & 0 deletions examples/versioncontrol/database/issues.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import {Entity} from "../../../";
import moment from "moment";
import {NotYetViewed, TicketTypes, IssueTicket, StatusTypes, toStatusString, toStatusCode} from "./types";
Expand Down
1 change: 1 addition & 0 deletions examples/versioncontrol/database/pullrequests.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import {Entity} from "../../../";
import moment from "moment";
import {NotYetViewed, TicketTypes, PullRequestTicket, StatusTypes, toStatusString, toStatusCode} from "./types";
Expand Down
1 change: 1 addition & 0 deletions examples/versioncontrol/database/repositories.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import {Entity} from "../../..";
import moment from "moment";

Expand Down
1 change: 1 addition & 0 deletions examples/versioncontrol/database/subscriptions.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import {Entity} from "../../../";
import moment from "moment";
import {TicketTypes, IsNotTicket} from "./types";
Expand Down
1 change: 1 addition & 0 deletions examples/versioncontrol/database/types.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import {IssueCommentIds, PullRequestCommentIds} from "./index";

export const StatusTypes = ["Open", "Closed"] as const;
Expand Down
1 change: 1 addition & 0 deletions examples/versioncontrol/database/users.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import {Entity} from "../../..";
import moment from "moment";

Expand Down
1 change: 1 addition & 0 deletions examples/versioncontrol/index.ts
@@ -1,3 +1,4 @@
/* istanbul ignore file */
// VersionControl (git) Service
// This example demonstrates more advanced modeling techniques using ElectroDB

Expand Down

0 comments on commit a57344c

Please sign in to comment.