Comments (4)
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.
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.
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.
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)
- Basic example error HOT 5
- How Do I Remove Edge HOT 5
- Support cursors without goroutines HOT 3
- Add support for jwt HOT 1
- Requests produce no result HOT 3
- Unmarshalling Result Has Duplicate Methods HOT 1
- Accessing error code from returned error HOT 2
- database.Run() response result (parsedResponse.Result) always empty HOT 3
- Quote in json value breaks the queries HOT 3
- bulk import API
- Support 3.x
- Possibility to get []byte instead of umarshaled struct as result HOT 2
- can connect multiple coordinator, and polling to send requests? HOT 1
- Prevent AQL injection in transaction HOT 1
- Adding new commands HOT 9
- Allow for extension of the library with change to Runnable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arangolite.