The following function is supposed to create a new user record in Users collection:
func arangodb() {
conn, err := http.NewConnection(http.ConnectionConfig{
Endpoints: []string{"http://root@localhost:8529"},
})
if err != nil {
panic(err)
}
c, err := driver.NewClient(driver.ClientConfig{
Connection: conn,
})
if err != nil {
panic(err)
}
// Open "examples_books" database
db, err := c.Database(nil, "_system")
if err != nil {
panic(err)
}
// Open "Users" collection
col, err := db.Collection(nil, "Users")
if err != nil {
panic(err)
}
type User struct {
name string
age int
}
// Create document
user := User{
name: "Bob",
age: 25,
}
meta, err := col.CreateDocument(nil, user)
if err != nil {
panic(err)
}
fmt.Printf("%+v", meta)
fmt.Printf("Created document in collection '%s' in database '%s'\n",
col.Name(), db.Name())
}
Executing the above function prints following message:
{Key:7018 ID:Users/7018 Rev:_Z9bZbdC---}Created document in collection 'Users' in database
'_system'
However in the web interface, the collection does not show the object created. It does show the _id, _rev and _key values and shows following for the object:
object{0}
(empty object)
My environment: macOS Cataline version 10.15.2 ArangoDB 3.6.1 Go version 1.13.6
Thanks for the help!