func writeTestData(ds dataset.Dataset, value types.Value) types.Ref { r1 := ds.Database().WriteValue(value) ds, err := ds.Commit(r1) d.Chk.NoError(err) err = ds.Database().Close() d.Chk.NoError(err) return r1 }
func addPerson(ds dataset.Dataset) { if flag.NArg() != 4 { fmt.Fprintln(os.Stderr, "Not enough arguments for command add-person") return } id, err := strconv.ParseUint(flag.Arg(1), 10, 64) if err != nil { fmt.Fprintf(os.Stderr, "Invalid person-id: %s", flag.Arg(1)) return } np := types.NewStruct("Person", map[string]types.Value{ "id": types.Number(id), "name": types.String(flag.Arg(2)), "title": types.String(flag.Arg(3)), }) ds.Commit(getPersons(ds).Set(types.Number(id), np)) }
func addCommitWithValue(ds dataset.Dataset, v types.Value) (dataset.Dataset, error) { return ds.Commit(v) }
func addCommit(ds dataset.Dataset, v string) (dataset.Dataset, error) { return ds.Commit(types.String(v)) }
func mergeDatasets(ds1, ds2 dataset.Dataset, v string) (dataset.Dataset, error) { p := types.NewSet(ds1.HeadRef(), ds2.HeadRef()) return ds1.Commit(types.String(v), dataset.CommitOptions{Parents: p}) }
func addBranchedDataset(newDs, parentDs dataset.Dataset, v string) (dataset.Dataset, error) { p := types.NewSet(parentDs.HeadRef()) return newDs.Commit(types.String(v), dataset.CommitOptions{Parents: p}) }