Skip to content

Commit

Permalink
Update docs for collections.set() (#868)
Browse files Browse the repository at this point in the history
* update jsdocs for set()

and fix examples

* version: [email protected]

---------

Co-authored-by: Joe Clark <[email protected]>
  • Loading branch information
mtuchi and josephjclark authored Dec 16, 2024
1 parent aa9315c commit e650595
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/collections/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/language-collections

## 0.7.1

### Patch Changes

- Fixed some small issues in the docs

## 0.7.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/collections/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-collections",
"version": "0.7.0",
"version": "0.7.1",
"description": "OpenFn collections adaptor",
"type": "module",
"exports": {
Expand Down
7 changes: 4 additions & 3 deletions packages/collections/src/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const setMockClient = mockClient => {
* @example <caption>Get a range of values from a collection with a key pattern</caption>
* collections.get('my-collection', '2024*')
* @example <caption>Get all values created since the end of January 2024</caption>
* collections.get('my-collection', { createdAfter: '202401')
* collections.get('my-collection', { createdAfter: '202401'})
*/
export function get(name, query = {}) {
return async state => {
Expand Down Expand Up @@ -126,14 +126,15 @@ export function get(name, query = {}) {
* a string key.
* @public
* @function
* @param {string} name - The name of the collection to fetch from
* @param keygen - a function which generates a key for each value: (value, index) => key. Pass a string to set a static key for a single item.
* @param values - an array of values to set, or a single value.
* @example <caption>Set a number of values using each value's id property as a key</caption>
* collections.set('my-collection', (item) => item.id, $.data)
* @example <caption>Set a number of values, generating an id from a string template</caption>
* collections.set('my-collection', (item) => `${item.category}-${Date.now()}`, $.data)
* @example <caption>Set a single value with a static key</caption>
* collections.set('my-collection', 'city-codes', { NY: 'New York', LDN: 'London' }})
* collections.set('my-collection', 'city-codes', { NY: 'New York', LDN: 'London' })
*/
export function set(name, keyGen, values) {
let argCount = arguments.length;
Expand Down Expand Up @@ -238,7 +239,7 @@ export function set(name, keyGen, values) {
* @example <caption>Remove a range of values from a collection with a key pattern</caption>
* collections.remove('my-collection', '2024*')
* @example <caption>Remove all values created since the end of January 2024</caption>
* collections.remove('my-collection', { createdAfter: '202401')
* collections.remove('my-collection', { createdAfter: '202401'})
*/
export function remove(name, query = {}, options = {}) {
return async state => {
Expand Down

0 comments on commit e650595

Please sign in to comment.