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

[DRAFT] Remove nested objects from documents, leave only one object per document #129

Open
cblp opened this issue Oct 8, 2019 · 1 comment

Comments

@cblp
Copy link
Member

cblp commented Oct 8, 2019

Current state

Now you can describe a number of nested objects, for example

(struct_set Note
  text RgaString
  tags (RGA (ObjectRef Tag))
  value Integer)

means that Note object chunk and chunks for all objects representing its fields (RGA for text and RGA for tags) will be stored inside the document frame.

All referenced objects (Tag in this example) will not be stored in this document, and the user has to put the explicitly into other documents.

This will generate a type like this:

data Note = Note
  { text :: RgaString, -- ~ [Char]
    tags :: RGA (ObjectRef Tag), -- ~ [UUID]
    value :: Integer
  }

RGA a is meant just to represent a value, so it is just a wrapper around [a].

A user can get the whole document state with the readObject function, with all internal objects decoded but without external object-refs resolved.

To resolve referenced objects, the user must take ObjectRefs and call loadDocument (involving IO) and readObject (in "pure" State) for them.

Problem

This seems unclear and complicated.

Proposal

  1. Put each object in its own document.
  2. Remove explicit ObjectRef from Schema, always considering a nested object a reference. Generated code will always contain references for objects.

Example

(struct_set Note
  text RgaString
  tags (RGA Tag)
  value Integer)
data Note = Note
  { text :: ObjectRef RgaString, -- ~ UUID
    tags :: ObjectRef RGA Tag, -- ~ UUID
    value :: Integer
  }

Open questions

  1. Does readObject load data from backend each time?
  2. What about transactions if there are no documents?
@cblp
Copy link
Member Author

cblp commented Nov 9, 2019

What about transactions if there are no documents?

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

No branches or pull requests

1 participant