GithubHelp home page GithubHelp logo

Add support to store metadata about logidze HOT 4 CLOSED

palkan avatar palkan commented on July 23, 2024
Add support to store metadata

from logidze.

Comments (4)

palkan avatar palkan commented on July 23, 2024 1

I like the proposed API (with_meta); we can implement it the same way as with_responsible.

record = Model.find(123)

Logidze.with_meta(test: 123) do
  record.update(attrs)
end

record.reload

# log_meta is equal to log_data.meta
meta = record.log_meta # => { "test" => 123 }

Note that the resulted Hash would have stringified keys (due to JSON encoding/decoding).

Feel free to propose a PR with the implementation!

from logidze.

anand180 avatar anand180 commented on July 23, 2024

I'm running into the same limitation on my end. My work-around at the moment is to use responsible_id as it can take an arbitrary string as its value

# store meta
Logidze.with_responsible({test: 123}.to_json) do
  Model.update(...)
end

# retrieve meta
meta = JSON.parse(log_data.responsible_id)

However, a better API would be something like

# store meta
Logidze.with_meta({test: 123}) do
  Model.update(...)
end

# retrieve meta
meta = log_data.meta # => {test: 123}

from logidze.

anand180 avatar anand180 commented on July 23, 2024

If there is some consensus on what the API should look like, I don't mind helping out with the implementation.

from logidze.

palkan avatar palkan commented on July 23, 2024

Closed by #79 and released as 0.7.0

from logidze.

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.