Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add basic docs for KeyValueRepository #1654

Merged
merged 1 commit into from
Aug 30, 2018
Merged

Conversation

raymondfeng
Copy link
Contributor

@raymondfeng raymondfeng commented Aug 29, 2018

Add basic docs for KeyValueRepository] using loopbackio/loopback4-example-shopping#4 as an example.

Checklist

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

@raymondfeng raymondfeng requested a review from bajtos as a code owner August 29, 2018 14:46
This was referenced Aug 29, 2018
Copy link
Contributor

@virkt25 virkt25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great docs! Some minor nitpicks.

### Define a KeyValue Datasource

We first need to define a datasource to configure the key-value store. For
better flexibility, we spilt the datasource definition into two files.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a reader I'm left wondering where is the flexibility? Is this covered in this doc somewhere before this point? If not we may want to mention that the flexibility comes from being able to inject the config into the DataSource class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: spilt change to split or splited ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Will fix.

### Define a KeyValueRepository

The KeyValueRepository binds a model such as `ShoppingCart` to the
`RedisDataSource`. The base `DefaultKeyValueRepository` provides an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base => case class

testKV();
```

[keyvaluerepository]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this would explain the broken links above, this should be KeyValueRepository.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh, prettier converts it to be lower case :-(.

## Persisting Data without Juggler [Using MySQL database]
## Access KeyValue Stores

We can now access key-value stores such as [redis](Redis) using the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing link for redis.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content LGTM, could you please double-check that all links work correctly.

### Perform Key Value Operations

The KeyValueRepository provides a set of key based operations, such as `set`,
`get`, `delete`, `expire`, `ttl`, and `keys`. See [KeyValueRepository] for a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See [KeyValueRepository] for a

Missing link?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix this before landing this PR.

@raymondfeng
Copy link
Contributor Author

Comments addressed. PTAL.

@raymondfeng raymondfeng merged commit f3290cd into master Aug 30, 2018
@raymondfeng raymondfeng deleted the add-kv-docs branch August 30, 2018 17:27
better flexibility, we spilt the datasource definition into two files. The json
file captures the configuration properties and it can be possibly overridden by
dependency injection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry to chime in, but wouldn't be good to add the following NOTE?. Especially for new LB4 adopters?

NOTE:
The prefix redis is related to the name of the data source, so you can use any name you want here. Usually you use lb4 datasource name to generate it, where name is the prefix mentioned above.

Copy link
Contributor Author

@raymondfeng raymondfeng Aug 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I didn't notice the context of the example-shopping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants