Closed Ranxy closed 3 years ago
Thank you @Ranxy! What do you think of this please? @Aiee @laura-ding
@Ranxy Thanks for your question. 'execute' applies to all NGQL's, and INSERT NGQL is just one. execute
is just a basic interface. The command splicing you want should be wrapped in another layer instead of being provided by execute
. Welcome to contribute such wrapper layer.
@laura-ding Ok, I will then start the wrapped task.
@laura-ding Ok, I will then start the wrapped task.
Thanks for your contribution.
@laura-ding Ok, I will then start the wrapped task.
Thank you @Ranxy!
Hi everyone, I have write a orm library support nebula write by go, now it's feature like this
Now i am test it in we production, and it will be a Open Source Project in one or two weeks later.
There are some example:
// init
func main() {
dalector := norm.MustNewDialector(norm.DialectorConfig{
Addresses: []string{"127.0.0.1:9669"},
Timeout: time.Second * 5,
})
db := norm.MustOpen(dalector, norm.Config{
Space: "test",
Username: "test",
Password: "test",
})
run(db)
}
func insertVertex(db *norm.DB) {
user := &examples.User{
VModel: norm.VModel{
Vid: "user_101",
},
ID: 101,
Created: 101,
}
err := db.Debug().InsertVertex(user)
if err != nil {
log.Errorf(context.TODO(), "insert %+v error: %v", user, err)
panic(err)
}
}
func insertEdge(db *norm.DB) {
vote := &examples.AnswerVoteUp{
EModel: norm.EModel{
Src: "user_101",
Dst: "answer_102",
},
VoteUpCnt: 101,
Created: 100000,
}
err := db.Debug().InsertEdge(vote)
if err != nil {
log.Errorf(context.TODO(), "insert %+v error: %v", vote, err)
panic(err)
}
}
func matchSingle(db *norm.DB) {
nsql := "match(v:user) where id(v)=='user_101' return v.id as id,v.created as created"
user := examples.User{}
err := db.Debug().ExecuteAndParse(nsql, &user)
if err != nil {
log.Errorf(context.TODO(), "exec %s error: %v", nsql, err)
panic(err)
}
log.Infof(context.TODO(), "%+v", user)
}
(forgive my poor english
What is the problem execute a stmt?
Now when we want to execute a stmt, We need to use string formatting to write an stmt like this
or just splice string like
this is not a good way to deal with.
What is proposed to do?
this will generate statements such as