Skip to content

v0.11.0

Compare
Choose a tag to compare
@merlimat merlimat released this 08 Oct 17:43
· 26 commits to main since this release
59dfd84

New Features

Secondary indexes.

It's now possible, when writing a record, to have it indexed by additional keys other than its primary key.

Example:

client.Put(ctx, "my-user-id", []byte(value), SecondaryIndex("name", "my-user-name"))

This will allow to do a List() or RangeScan() operation based on the secondary index, instead of the primary key:

resCh := client.RangeScan(ctx, "A", "M", UseIndex("name"))
list, err := client.List(ctx, "A", "M", UseIndex("name"))

The returned list will be a list of the primary keys that match the boundaries in the secondary index.

Notes:

  1. The secondary key is not required to be unique (unlike the primary key for the record)
  2. A single record can have more that 1 secondary index (eg: index by name, age, location...)
  3. There can be multiple secondary keys for the same secondary index. eg:
client.Put(ctx, "my-user-id", []byte(value), 
      SecondaryIndex("ref", "my-ref-1"),
      SecondaryIndex("ref", "my-ref-2"),
)

What's Changed

Full Changelog: v0.10.0...v0.11.0