Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
add recurse note
Browse files Browse the repository at this point in the history
  • Loading branch information
bketelsen authored and rawkode committed Sep 7, 2021
1 parent ed88024 commit 48e0a8f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/cuedb/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,19 +444,27 @@ func (r *Engine) GetOutput() (cue.Value, error) {

func (r *Engine) flatten(d DataSet) error {
for _, rel := range d.relationships {
d.

foreignTable, err := r.GetDataSet(strings.ToLower(rel))
if err != nil {
return err
}
// Step 3. Get foreign key dataset data path
foreignDataPath := foreignTable.CueDataPath()
fmt.Println(foreignDataPath)
// RI version
inst, err := r.CueRuntime.Compile("", fmt.Sprintf("{data: _\n%s: %s: %s%s: or([ for k, _ in data.%s {k}])}", dataSet.GetInlinePath(), dataSet.name, fields.Label(), optional, foreignTable.GetDataDirectory()))
// output version
inst, err := r.CueRuntime.Compile("", fmt.Sprintf("{%s: %s: _\noutput: %s: [ for key, val in %s.%s {val}]}", dataPathRoot, dataSet.metadata.Plural, dataSet.metadata.Plural, dataPathRoot, dataSet.metadata.Plural))

// need data source from RI version
// output from output version
// but add the field as {relationship}_value or something similar

// Step 4. Augment first definition with new constraint

// step 5: recurse

}
return nil
}

0 comments on commit 48e0a8f

Please sign in to comment.