本文整理匯總了Golang中github.com/jmcvetta/neoism.Database.GetOrCreateNode方法的典型用法代碼示例。如果您正苦於以下問題:Golang Database.GetOrCreateNode方法的具體用法?Golang Database.GetOrCreateNode怎麽用?Golang Database.GetOrCreateNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/jmcvetta/neoism.Database
的用法示例。
在下文中一共展示了Database.GetOrCreateNode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetOrCreateNode
// GetOrCreateNode returns a Node, creates one if it does not exist. This method
// overrides the neoism one as there is a bug
func GetOrCreateNode(db *neoism.Database, label, key string, p neoism.Props) (n *neoism.Node, created bool, err error) {
node, created, err := db.GetOrCreateNode(util.UpperCaseFirst(label), key, p)
// due to a bug in neoism, label is not added
// see: https://github.com/jmcvetta/neoism/issues/62
if created {
node.AddLabel(util.UpperCaseFirst(label))
}
return node, created, err
}
示例2: getEntity
func (s *state) getEntity(db *neoism.Database, xid string) *neoism.Node {
p := neoism.Props{"_xid_": xid}
e, created, err := db.GetOrCreateNode("Entity", "_xid_", p)
if err != nil {
glog.Fatal(err)
}
if created {
e.AddLabel("Entity")
glog.WithFields(logrus.Fields{
"id": e.Id(),
"_xid_": xid,
}).Debug("Added new entity")
}
return e
}
示例3: createUrls
func createUrls(db *neoism.Database) {
db.GetOrCreateNode("Url", "address", neoism.Props{"address": "http://www.google.com"})
db.GetOrCreateNode("Url", "address", neoism.Props{"address": "http://www.yahoo.com"})
db.GetOrCreateNode("Url", "address", neoism.Props{"address": "http://www.cnn.com"})
}