Giter Club home page Giter Club logo

Comments (8)

dstpierre avatar dstpierre commented on August 23, 2024 1

hey @szymonnogiec great. I just read the description, this issue was created prior to having the Persister interface, so let me give an updated guide line here:

Starting from the database sub-packages, you'd have 3 implementation to do, the postgresql, mongo, and memory.

I'd start by implementing the memory one by creating a test and your implementation.

You may test only the memory implementation with make test-mem at the project root.

I'd create two new functions in the base.go file UpdateDocuments and DeleteDocuments matching their non pluralized counter part.

Look at how the QueryDocuments function uses criteria to be a bit inspired, you may look at the TestQueryDocuments function in memory/base_test.go to start writing the TestUpdateDocuments and TestDeleteDocuments tests.

Once you have a working implementation, you might want to add those two function in the internal/persister.go Persister interface and go write the implementation and tests for both postgresql and mongo packages.

The last step will be to modify the update and delete endpoints of the API to handle receiving criteria.

You'll noticed in the db.go:26 the following:

} else if r.Method == http.MethodPut {
  database.update(w, r)
} else if r.Method == http.MethodDelete {
  database.del(w, r)
}

For the update, one simple idea to handle the criteria would be to have a query string parameter in the URL and if present call a new handler that will be able to accept a more complex data object for instance:

{
  "criteria": [],
  "update": {}
}

Where the criteria is the [][]interface{} as seen in the query function of db.go:152. The code that parses the criteria / filters should be extracted from there since it will be re-used by the query function and the two new function that you'll be creating.

Those are just suggestions, feel free to explore and use different ways etc.

Let me know if you have any questions.

from core.

szymonnogiec avatar szymonnogiec commented on August 23, 2024

Hey, I want to work on this issue;

from core.

rostikts avatar rostikts commented on August 23, 2024

Hello! @dstpierre @szymonnogiec don't you mind If I'll take a look as well?

from core.

dstpierre avatar dstpierre commented on August 23, 2024

Hey @rostikts it's awesome you want to work on this. @szymonnogiec started a couple of weeks ago, maybe you could reach them and see if there's way to collaborate on this. The issue is kind of big so I suppose it could be broken down into smaller tasks.

If you're not on Discord - join link yet, I'd suggest you join us there

Let me know how I can help with anything.

from core.

dstpierre avatar dstpierre commented on August 23, 2024

Hey @rostikts - @szymonnogiec replied in Discord and this issue could be split into two. One of you take the update part and the other the deletion part.

from core.

dstpierre avatar dstpierre commented on August 23, 2024

@szymonnogiec hey how things are going? Can I help with anything?

For the delete part, you may take a look at @rostikts changes for the update and reuse a similar approach / reuse the filtering codee.

Let us know if you have any question, I'd be happy to help you get started and/or unblock for this 👋

from core.

dstpierre avatar dstpierre commented on August 23, 2024

Hey @szymonnogiec last time you confirmed via Discord that you'd still want to tackle this one. Are you still interested? I'm planning a new release and I'd like that one to be part of the next version.

Let me know where things are please, thanks.

from core.

dstpierre avatar dstpierre commented on August 23, 2024

implemented the remaining bulk delete in #79 completing this bulk update/delete feature.

from core.

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.