I'm developing a website to learn how to use golang packages:
github.com/gin-gonic/gin
, andgithub.com/johnnadratowski/golang-neo4j-bolt-driver
.I have a User
struct like that
type User struct {
Id int16 `json:"id" db:"id"`
Username string `json:"username" db:"username"`
Email string `json:"email" db:"email"`
CreatedAt time.Time `json:"created_at" db:"created_at"
}
and i want to create a node in neo4j with all this information
func test(u User) {
m := structs.Map(u)
app.Neo.ExecNeo("CREATE (n:NODE {Id: {Id}, Username: {Username}, "+
"Email: {Email}, CreatedAt: {CreatedAt}})", m)
}
because of the format of the date "0001-01-01 00:00:00 +0000 UTC" neo4j does't accept the query (everything work if i remove the CreatedAt
).
So, I wanted to know how i can format it, are there any tips? or do i have to write my own function?
Thanks to the comments I'have found the solution I needed to format the date time from "0001-01-01 00:00:00 +0000 UTC"
to "0001-01-01T00:00:00+0000"
.
ex : CREATE (n:NODE {Id: 2, Username: "Toto", Email: "Toto@titi.com", CreateAt:'0001-01-01T00:00:00'})