Coder Social home page Coder Social logo

Make db fields public about arangolite HOT 4 OPEN

solher avatar solher commented on July 18, 2024
Make db fields public

from arangolite.

Comments (4)

solher avatar solher commented on July 18, 2024

When you say creating a new database, you mean creating a new database object right?
You can easily switch any parameter at any moment using the Options method, as shown in the documented Basic Usage:

  // We declare the database definition.
  db := arangolite.NewDatabase(
    arangolite.OptEndpoint("http://localhost:8529"),
    arangolite.OptBasicAuth("root", "rootPassword"),
    arangolite.OptDatabaseName("_system"),
  )

  // The Connect method does two things:
  // - Initializes the connection if needed (JWT authentication).
  // - Checks the database connectivity.
  if err := db.Connect(ctx); err != nil {
    log.Fatal(err)
  }

  // We create a new database.
  err := db.Run(ctx, nil, &requests.CreateDatabase{
    Name: "testDB",
    Users: []map[string]interface{}{
      {"username": "root", "passwd": "rootPassword"},
      {"username": "user", "passwd": "password"},
    },
  })
  if err != nil {
    log.Fatal(err)
  }

  // We sign in as the new created user on the new database.
  // We could eventually rerun a "db.Connect()" to confirm the connectivity.
  db.Options(
    arangolite.OptBasicAuth("user", "password"),
    arangolite.OptDatabaseName("testDB"),
  )

What kind of difficulties are you encountering?

from arangolite.

virmundi avatar virmundi commented on July 18, 2024

I need to be able to read the database name. Presently I have to manually keep track of the value through the call stack. For example, when creating a migration I first start with _system to see if the database the user specifies is there. If not, I look to see if the first migration step is creating the db. if so I execute that then switch to the new db after creation. All this time I have to hold onto the current db to see if it's _system.

from arangolite.

solher avatar solher commented on July 18, 2024

Oh ok for read operations good point.

I'm just trying to keep the tiniest API surface possible to be able to refactor easily in case of missing features (and there are probably a lot). For example, if I had publicly exposed the authentication user/password, I would have been blocked when adding the JWT auth support (the credentials are not in the Database object anymore).

Would a getter on the current database name be good enough in your case? Anything else you would like to be able to do?

from arangolite.

virmundi avatar virmundi commented on July 18, 2024

I think getting the read operations would help. I'll open another ticket for a feature request on another topic.

from arangolite.

Related Issues (17)

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.