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

Replace [Schema]/[Collection]By[Foo] funcs with filterable param #2008

Closed
AndrewSisley opened this issue Oct 27, 2023 · 1 comment · Fixed by #2319
Closed

Replace [Schema]/[Collection]By[Foo] funcs with filterable param #2008

AndrewSisley opened this issue Oct 27, 2023 · 1 comment · Fixed by #2319
Assignees
Labels
area/collections Related to the collections system area/schema Related to the schema system feature New feature or request
Milestone

Comments

@AndrewSisley
Copy link
Contributor

At the moment we have these two sets of functions on client.Store:

GetCollectionByName
GetCollectionsBySchemaRoot
GetCollectionsByVersionID
GetAllCollections
GetSchemasByName
GetSchemaByVersionID
GetSchemasByRoot
GetAllSchemas

As well as being a lot more numerous than they need to be, they are also limited in that you can't fetch by multiple params (e.g. filter by Name and Root).

We should consider replacing them with something along the lines of:

struct Filter {
  Name Option[String]
  Root Option[String]
  ID Option[String]
}
GetCollections(...CollectionFilter)
GetSchemas(...SchemaFilter)
@AndrewSisley AndrewSisley added feature New feature or request area/schema Related to the schema system area/collections Related to the collections system labels Oct 27, 2023
@nasdf
Copy link
Member

nasdf commented Oct 27, 2023

I like this simplification. I'd also suggest adding some simple helpers:

type CollectionFilterOptions {
  Name Option[String]
  Root Option[String]
  ID Option[String]
}

var CollectionFilter CollectionFilterOptions{}

func (f CollectionFilterOptions) ByName(name string) CollectionFilterOptions {
  f.Name = name
  return f
}

...

CollectionFilter.ByName("Users")

@AndrewSisley AndrewSisley self-assigned this Feb 15, 2024
@AndrewSisley AndrewSisley added this to the DefraDB v0.10 milestone Feb 15, 2024
AndrewSisley added a commit that referenced this issue Feb 20, 2024
## Relevant issue(s)

Resolves #2008

## Description

Reworks the GetCollection/SchemaByFoo funcs into single GetCollections
and GetSchemas funcs.
shahzadlone pushed a commit to shahzadlone/defradb that referenced this issue Feb 23, 2024
…rk#2319)

## Relevant issue(s)

Resolves sourcenetwork#2008

## Description

Reworks the GetCollection/SchemaByFoo funcs into single GetCollections
and GetSchemas funcs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/collections Related to the collections system area/schema Related to the schema system feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants