• brisk@aussie.zone
    link
    fedilink
    arrow-up
    5
    ·
    6 days ago

    Isn’t a database only as global as you make it? The connection is surely a real object that needs to be passed around and referenced just like any other.

    I don’t really touch JavaScript or web dev so I might be misunderstanding the domain usage.

    • swicano@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      5 days ago

      I think his point is more that you might have multiple components that need database access in your app, so those component have a connection (or reuse a central access) and for simplicity reasons, you made 1 database for the whole app, rather than one per component. Once that happens there’s a new path that could be used to pass information between the components in a way that isn’t the function interface. Much like a global variable can be used that way. And there’s a risk you start to use the database like a global variable store.

      I don’t use databases much, so I don’t have a strong opinion, but it’s an interesting thought.