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

Reorganize Set, Map and descriptorPrototype types handling #38

Open
medikoo opened this issue Jul 23, 2015 · 1 comment
Open

Reorganize Set, Map and descriptorPrototype types handling #38

medikoo opened this issue Jul 23, 2015 · 1 comment
Assignees
Milestone

Comments

@medikoo
Copy link
Owner

medikoo commented Jul 23, 2015

/cc @kamsi @mtuchowski

Currently, Set is defined via multiple: true, and Map (when we think of object with each property of same type) via _desciptorPrototype_.setProperties({ type: Object, nested: true }).

It doesn't seem intuitive, and probably can be improved, by removing both multiple: true and descriptorPrototype functions, and instead introducing aside of type meta property, an itemType property

So sets can be defined as:

Class.prototype.defineProperty('someSet', { type: db.Set, itemType: db.String })

and maps as e.g.:

Class.prototype.defineProperty('someMap', { type: db.Object, itemType: db.String })

Additionally for object kind of itemType's we may introduce (optional) itemPrototype property, which will allow to customise type provided for itemType without a need to create such type as standalone one. That thing is not possible in current implementation of dbjs (all we have is _descriptorPrototype_)

@medikoo medikoo added this to the v0.1 milestone Jul 23, 2015
@medikoo medikoo self-assigned this May 2, 2016
@medikoo
Copy link
Owner Author

medikoo commented Oct 18, 2023

Reiterating on this years later:

Ideally if object types are organized as follows:

  • Map (generic object type, in current version represented by Object). Keys accept any values, Values accept any values and null. Aside provide built-in support for keyType and itemType through which keys and/or values can be restricted to specific type
  • Set - Map extension, with values restricted to null type
  • Object - Map extension with keys restricted to String type

Having that all multiple properties, will be reflected with property of Set type, in most cases additionally restricted through keyType (so e.g. to have list of strings, we'd need Set with keyType set to String)

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

No branches or pull requests

1 participant