Giter Site home page Giter Site logo

set multiple keys at once about irmin HOT 2 CLOSED

hannesm avatar hannesm commented on June 12, 2024
set multiple keys at once

from irmin.

Comments (2)

hannesm avatar hannesm commented on June 12, 2024 1

Thanks for your suggestion. For a future reader, the full code I now use is:

let push_to_branch repository ~branch data =
  let config = Irmin_git.config repository in
  Store.Repo.v config >>= fun repo ->
  Store.of_branch repo branch >>= fun s ->
  Store.tree s >>= fun tree ->
  M.fold (fun k v tree ->
      tree >>= fun tree ->
      Store.Tree.add tree (String.split_on_char '/' k) v)
    data (Lwt.return tree) >>= fun tree ->
  let info =
    let author = "Canopy bot <[email protected]>" in
    Irmin_git_unix.info ~author "%s" "updated" ()
  in
  (Store.Head.find s >|= function
    | None -> []
    | Some commit -> [ Commit.key commit ]) >>= fun parents ->
  Store.Commit.v repo ~info ~parents tree >>= fun commit ->
  Store.Head.set s commit

Thanks again @Ngoguey42

from irmin.

Ngoguey42 avatar Ngoguey42 commented on June 12, 2024

Hi.

In order to batch operations under a single commit you need to use the irmin trees:

  Store.of_branch repo branch >>= fun s ->
  Store.tree s >>= fun tree ->

  (* add one contents at a time *)
  Store.Tree.add tree (String.split_on_char '/' k) v >>= fun tree -> 

  Store.Commit.v repo ~info ~parents tree >>= fun _commit ->

I hope it helps.

from irmin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.