Skip to content

Commit

Permalink
Merge pull request #101 from nitrictech/develop
Browse files Browse the repository at this point in the history
Release v0.3.1
  • Loading branch information
tjholm authored Feb 28, 2022
2 parents b5db1cb + df4bd10 commit 1a3d340
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 44 deletions.
32 changes: 1 addition & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,5 @@ The NodeJS SDK supports the use of the cloud-portable [Nitric](https://nitric.io

## Getting Started

### Using the [Nitric CLI](https://github.com/nitric-tech/cli)
> @nitric/sdk is included in all node related SDK projects by default
Checkout the [nitric docs](https://nitric.io/docs) to see how to get started using nitric

```bash
nitric make:stack <node-stack> example
```

Some available node stacks are:

* typescript
* javascript


### Adding to an existing project
**NPM**
```bash
npm install @nitric/sdk
```
**Yarn**
```bash
yarn add @nitric/sdk
```

## Usage
[Nitric Documentation](https://nitric.io/docs)

## Local Development

```bash
yarn install
yarn build
```
16 changes: 8 additions & 8 deletions src/api/documents/v0/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { documents, Documents } from './documents';
import { DocumentSnapshot } from './document-snapshot';
import { InvalidArgumentError, UnimplementedError } from '../../errors';
import { DocumentRef } from './document-ref';

describe('Query Tests', () => {
describe('Adding a where clause to a query', () => {
Expand Down Expand Up @@ -295,14 +296,13 @@ describe('Query Tests', () => {
chunks.push(chunk);
}

expect(chunks).toStrictEqual([
{
content: {
id: 'test',
},
ref: mockKey,
},
]);
expect(chunks[0] instanceof DocumentSnapshot).toBe(true);

const snapShot = chunks[0] as DocumentSnapshot<any>;

expect(snapShot.content).toStrictEqual({
id: 'test',
});
});

test('The Grpc client for DocumentServiceClient.QueryStream should have been called exactly once', () => {
Expand Down
14 changes: 9 additions & 5 deletions src/api/documents/v0/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,17 @@ export class Query<T extends { [key: string]: any }> {

const transform = new Transform({
objectMode: true,
transform(result: DocumentQueryStreamResponse, encoding, callback) {
transform: (result: DocumentQueryStreamResponse, encoding, callback) => {
const doc = result.getDocument();

callback(undefined, {
ref: doc.getKey(),
content: doc.getContent().toJavaScript() as T,
});
callback(undefined, new DocumentSnapshot<T>(
new DocumentRef<T>(
this.documentClient,
this.collection,
doc.getKey().getId()
),
doc.getContent().toJavaScript() as T
));
},
});

Expand Down

0 comments on commit 1a3d340

Please sign in to comment.