• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang neoism.Connect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/jmcvetta/neoism.Connect函数的典型用法代码示例。如果您正苦于以下问题:Golang Connect函数的具体用法?Golang Connect怎么用?Golang Connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Connect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: UseTicket

func UseTicket(tickets util.Ticket_struct) (string, error) {
	fmt.Printf("Accessing NEO4J Server Cyphering UseTicket\n")
	database, err := neoism.Connect("http://neo4j:[email protected]:7474/db/data")

	if err != nil {
		fmt.Printf("NEO4J Connection FAILED\n")
		return "Internal Service Error", err
	}

	cq := neoism.CypherQuery{
		Statement: `
		MATCH (t:Ticket)
		WHERE t.ID = {user_id} AND t.COUPON_ID = {id}
		SET t.VALID = "FALSE"
	`,
		Parameters: neoism.Props{"user_id": tickets.ID, "id": tickets.COUPON_ID},
	}
	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return "Internal Service Error", err
	}

	return "Success", nil
}
开发者ID:Damian3395,项目名称:DB_PROJECT,代码行数:25,代码来源:tickets.go


示例2: runServer

func runServer(neoURL string, port int) {
	var err error
	db, err = neoism.Connect(neoURL)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("connected to %s\n", neoURL)
	neoutils.EnsureIndexes(db, map[string]string{
		"Thing": "uuid",
	})

	m := mux.NewRouter()
	http.Handle("/", m)

	m.HandleFunc("/content/{content_uuid}/annotations/annotated_by/{concept_uuid}", writeHandler).Methods("PUT")
	m.HandleFunc("/annotations/", allWriteHandler).Methods("PUT")
	cw = neocypherrunner.NewBatchCypherRunner(neoutils.StringerDb{db}, 1024)

	log.Printf("listening on %d", port)
	if err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil); err != nil {
		log.Printf("web stuff failed: %v\n", err)
	}

}
开发者ID:Financial-Times,项目名称:annotations-api-neo,代码行数:25,代码来源:annotations_api_neo.go


示例3: connect

func connect() *neoism.Database {
	db, err := neoism.Connect("http://localhost:7474/db/data")
	if err != nil {
		log.Fatal(err)
	}
	return db
}
开发者ID:zombor,项目名称:neoism,代码行数:7,代码来源:presentation.go


示例4: connectDefault

func connectDefault(neoURL string, conf *ConnectionConfig) (NeoConnection, error) {

	db, err := neoism.Connect(neoURL)
	if err != nil {
		return nil, err
	}

	if conf.HTTPClient != nil {
		db.Session.Client = conf.HTTPClient
	}

	exeName, err := osutil.Executable()
	if err == nil {
		_, exeFile := filepath.Split(exeName)
		db.Session.Header.Set("User-Agent", exeFile+" (using neoutils)")
	}

	var cr CypherRunner = db
	if conf.Transactional {
		cr = TransactionalCypherRunner{db}
	} else {
		cr = db
	}

	if conf.BatchSize > 0 {
		cr = NewBatchCypherRunner(cr, conf.BatchSize)
	}

	ie := &defaultIndexEnsurer{db}

	return &DefaultNeoConnection{neoURL, cr, ie, db}, nil
}
开发者ID:Financial-Times,项目名称:neo-utils-go,代码行数:32,代码来源:connection.go


示例5: UrlsIndexHandler

func UrlsIndexHandler(w http.ResponseWriter, req *http.Request) {
	neo, err := neoism.Connect(os.Getenv("GRAPHENEDB_URL"))

	if err != nil {
		printer.JSON(w, http.StatusServiceUnavailable, map[string]interface{}{
			"code":    http.StatusServiceUnavailable,
			"error":   http.StatusText(http.StatusServiceUnavailable),
			"message": err,
		})
	} else {
		urls := []Url{}
		cq := neoism.CypherQuery{
			Statement: `MATCH (url:Url) RETURN url`,
			Result:    &urls,
		}
		err := neo.Cypher(&cq)
		if err != nil {
			printer.JSON(w, http.StatusServiceUnavailable, map[string]interface{}{
				"code":    http.StatusServiceUnavailable,
				"error":   http.StatusText(http.StatusServiceUnavailable),
				"message": err,
			})
		}
		printer.JSON(w, http.StatusOK, map[string][]Url{"urls": urls})
	}
}
开发者ID:glevine,项目名称:burl,代码行数:26,代码来源:server.go


示例6: getUserTickets

func getUserTickets(res *[]struct {
	A string `json:"n.COUPON_ID"`
}, id string) error {
	database, err := neoism.Connect("http://neo4j:[email protected]:7474/db/data")

	if err != nil {
		fmt.Printf("NEO4J Connection FAILED\n")
		return err
	}

	cq := neoism.CypherQuery{
		Statement: `
			MATCH (n:Ticket)
			WHERE n.ID = {user_id}
			RETURN n.COUPON_ID
		`,
		Parameters: neoism.Props{"user_id": id},
		Result:     &res,
	}
	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return err
	}

	return nil
}
开发者ID:Damian3395,项目名称:DB_PROJECT,代码行数:27,代码来源:searchEngine.go


示例7: RemoveCoupon

func RemoveCoupon(coupon util.GetCoupon_struct) (string, error){
	fmt.Printf("Accessing NEO4J Server Cyphering RemoveCoupon\n")
	database, err := neoism.Connect("http://neo4j:[email protected]:7474/db/data")
	
	if err != nil {
		fmt.Printf("NEO4J Connection FAILED\n")
		return "Internal Service Error", err	
	}
	
	cq := neoism.CypherQuery{
    Statement: `
    	MATCH (n:Coupon)
      	WHERE n.ID = {user_id} AND n.COUPON_ID = {coupon_id} 
       	DELETE n
    `,
    Parameters: neoism.Props{"user_id": coupon.ID, "coupon_id": coupon.COUPON_ID},
	}
	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return "Internal Service Error", err
	}

	return "Success", nil
}
开发者ID:Damian3395,项目名称:DB_PROJECT,代码行数:25,代码来源:coupon.go


示例8: UpdateBusinessGeneral

func UpdateBusinessGeneral(update util.UpdateGeneralBusiness_struct) (string, error) {
	fmt.Printf("Accessing NEO4J Server: Cyphering UpdateBusinessGeneral\n")

	database, err := neoism.Connect("http://neo4j:[email protected]:7474/db/data")

	if err != nil {
		fmt.Printf("NEO4J Connection FAILED\n")
		return "Internal Service Error", err
	}

	res := []struct {
		A string `json:"n.NAME"`
	}{}

	res2 := []struct {
		A string `json:"n.NAME"`
	}{}

	cq := neoism.CypherQuery{
		Statement: `
        	MATCH (n:Activity)
       		WHERE n.ID = {user_id}
			SET n.NAME = {name}, n.MIN_AGE = {min_age}, n.MAX_AGE = {max_age}, n.MIN_PEOPLE = {min_people},
									n.MAX_PEOPLE = {max_people}, n.MAIN_CATEGORY = {main_category}, n.SUB_CATEGORY = {sub_category}
        	RETURN n.NAME
    	`,
		Parameters: neoism.Props{"user_id": update.ID, "name": update.NAME, "min_age": update.MIN_AGE,
			"max_age": update.MAX_AGE, "min_people": update.MIN_PEOPLE, "max_people": update.MAX_PEOPLE,
			"main_category": update.MAIN_CATEGORY, "sub_category": update.SUB_CATEGORY},
		Result: &res,
	}

	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return "Internal Service Error", err
	}

	cq = neoism.CypherQuery{
		Statement: `
        	MATCH (n:Coupon)
       		WHERE n.ID = {user_id}
        	SET	n.NAME = {name}
			RETURN n.NAME
    	`,
		Parameters: neoism.Props{"user_id": update.ID, "name": update.NAME},
		Result:     &res2,
	}
	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return "Internal Service Error", err
	}

	if len(res) == 1 && len(res2) == 1 {
		return "Success", nil
	}

	return "Error: User Not Found", nil
}
开发者ID:Damian3395,项目名称:DB_PROJECT,代码行数:60,代码来源:updateBusiness.go


示例9: FindCoupon

func FindCoupon(id string) (bool, error) {
	database, err := neoism.Connect("http://neo4j:[email protected]:7474/db/data")

	if err != nil {
		fmt.Printf("NEO4J Connection FAILED\n")
		return false, err
	}

	res := []struct {
		A string `json:"n.ID"`
	}{}

	cq := neoism.CypherQuery{
		Statement: `
        	MATCH (n:Coupon)
       		WHERE n.COUPON_ID = {id}
        	RETURN n.ID
    	`,
		Parameters: neoism.Props{"id": id},
		Result:     &res,
	}

	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return false, err
	}

	if len(res) == 0 {
		return false, nil
	}

	return true, nil
}
开发者ID:Damian3395,项目名称:DB_PROJECT,代码行数:34,代码来源:tools.go


示例10: LoginBusiness

func LoginBusiness(login Util.Login_struct) (string, error) {
	fmt.Printf("Accessing NEO4J Server Cyphering BusinessLogin\n")
	database, err := neoism.Connect("http://neo4j:[email protected]:7474/db/data")

	if err != nil {
		fmt.Printf("NEO4J Connection FAILED\n")
		return "Internal Service Error", err
	}

	res := []struct {
		A string `json:"n.USER_ID"`
	}{}

	cq := neoism.CypherQuery{
		Statement: `
        	MATCH (n:Business)
       		WHERE n.USER_ID = {user_id} AND n.PASSWORD = {password}
        	RETURN n.USER_ID
    	`,
		Parameters: neoism.Props{"user_id": login.ID, "password": login.PASSWORD},
		Result:     &res,
	}
	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return "Internal Service Error", err
	}

	if len(res) == 1 {
		return "Success", nil
	}

	fmt.Printf("Business User Login Failed\n")
	return "Failed", nil
}
开发者ID:Damian3395,项目名称:DB_PROJECT,代码行数:35,代码来源:login.go


示例11: Connect

func (db *Database) Connect(hostname string) (database *neoism.Database, ok int) {
	database, err := neoism.Connect("http://127.0.0.1:7474/db/data")
	if err != nil {
		log.Fatal(err)
	}
	db.db = database
	return
}
开发者ID:vly,项目名称:ssdir,代码行数:8,代码来源:neo.go


示例12: init

func init() {
	resetDB()
	var err error
	db, err = neoism.Connect("http://localhost:7474/db/data")
	if err != nil {
		panic(err)
	}
}
开发者ID:yeaz,项目名称:neo4j-tutorials,代码行数:8,代码来源:main.go


示例13: GetActiveCoupons

func GetActiveCoupons(coupon util.GetCoupon_struct) (string, error){
	fmt.Printf("Accessing NEO4J Server Cyphering GetActiveCoupon\n")
	database, err := neoism.Connect("http://neo4j:[email protected]:7474/db/data")
	
	if err != nil {
		fmt.Printf("NEO4J Connection FAILED\n")
		return "Internal Service Error", err	
	}
	
	res := []struct {
		N neoism.Node 
    }{}

	cq := neoism.CypherQuery{
    Statement: `
    	MATCH (n:Coupon)
      	WHERE n.ID = {user_id} AND n.VALID = "TRUE"
       	RETURN n
    `,
    Parameters: neoism.Props{"user_id": coupon.ID},
    Result:     &res,
	}
	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return "Internal Service Error", err
	}

	response := ""
	data := map[string]interface{}{}
	if len(res) != 0 {
		jsonString := "{\"coupons\": ["
		for i:=0; i < len(res); i++ {
			coupon, err := json.Marshal(res[i].N.Data)
			if err != nil {
				fmt.Printf("%s\n", err)
			}	
			jsonString += string(coupon)
			if i != (len(res)-1){
				jsonString += ","
			}
		}
		jsonString += "]}"

		dec := json.NewDecoder(strings.NewReader(jsonString))
		dec.Decode(&data)
		
		coupons, err := json.Marshal(data)
		if err != nil {
			fmt.Printf("%s\n", err)
		}
		response = string(coupons)
			
		return response, nil
	}

	return "No Active Coupons", nil
}
开发者ID:Damian3395,项目名称:DB_PROJECT,代码行数:58,代码来源:coupon.go


示例14: UpdateBusinessAddress

func UpdateBusinessAddress(update util.UpdateAddressBusiness_struct) (string, error) {
	fmt.Printf("Accessing NEO4J Server: Cyphering UpdateBusinessAddress\n")

	database, err := neoism.Connect("http://neo4j:[email protected]:7474/db/data")

	if err != nil {
		fmt.Printf("NEO4J Connection FAILED\n")
		return "Internal Service Error", err
	}

	res := []struct {
		A string `json:"n.NAME"`
	}{}

	res2 := []struct {
		A string `json:"n.NAME"`
	}{}

	cq := neoism.CypherQuery{
		Statement: `
        	MATCH (n:Activity)
       		WHERE n.ID = {user_id}
        	SET n.ADDRESS = {address}, n.TOWNSHIP = {township}, n.CAMPUS = {campus}
			RETURN n.NAME
    	`,
		Parameters: neoism.Props{"user_id": update.ID, "address": update.ADDRESS, "township": update.TOWNSHIP, "campus": update.CAMPUS},
		Result:     &res,
	}

	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return "Internal Service Error", err
	}

	cq = neoism.CypherQuery{
		Statement: `
        	MATCH (n:Coupon)
       		WHERE n.ID = {user_id}
        	SET n.ADDRESS = {address}, n.CAMPUS = {campus}
			RETURN n.NAME
    	`,
		Parameters: neoism.Props{"user_id": update.ID, "address": update.ADDRESS, "campus": update.CAMPUS},
		Result:     &res2,
	}

	err = database.Cypher(&cq)
	if err != nil {
		fmt.Printf("Error Cyphering To Database\n")
		return "Internal Service Error", err
	}

	if len(res) == 1 && len(res2) == 1 {
		return "Success", nil
	}

	return "Error: User Not Found", nil
}
开发者ID:Damian3395,项目名称:DB_PROJECT,代码行数:58,代码来源:updateBusiness.go


示例15: main

func main() {
	neo, err := neoism.Connect(os.Getenv("GRAPHENEDB_URL"))
	if err != nil {
		fmt.Println(err)
		return
	}

	createUrls(neo)
}
开发者ID:glevine,项目名称:burldemo,代码行数:9,代码来源:demo.go


示例16: NewQuery

// Constructor, use this when creating a new Query struct.
func NewQuery(uri string) *Query {
	neo4jdb, err := neoism.Connect(uri)
	panicIfErr(err)

	query := Query{neo4jdb}
	query.DatabaseInit()

	return &query
}
开发者ID:AbdulZaid,项目名称:cher-ami,代码行数:10,代码来源:query.go


示例17: Cleanup

func Cleanup() {
	db, _ := neoism.Connect("http://neo4j:[email protected]:7474")
	cq := neoism.CypherQuery{
		Statement: `MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r`,
	}
	if err := db.Cypher(&cq); err != nil {
		panic(err)
	}
}
开发者ID:nathandao,项目名称:neo4jstore,代码行数:9,代码来源:neo4jstore_cleanup.go


示例18: connect

func connect(app *App) {
	url := app.Config.Neo4JUrl
	var db *neoism.Database
	db, err := neoism.Connect(url)
	if err != nil {
		log.Fatal("Could not connect to DB", err)
	}
	app.GraphDB = db
}
开发者ID:squeed,项目名称:gpg2graph,代码行数:9,代码来源:db.go


示例19: main

func main() {
	flag.Parse()

	numCpus := runtime.NumCPU()
	prevProcs := runtime.GOMAXPROCS(*threads)
	glog.WithField("num_cpu", numCpus).
		WithField("threads", *threads).
		WithField("prev_maxprocs", prevProcs).
		Info("Set max procs to threads")

	if len(*rdfGzips) == 0 {
		glog.Fatal("No RDF GZIP files specified")
	}

	db, err := neoism.Connect("http://localhost:7474/db/data")
	if err != nil {
		log.Fatal(err)
	}

	files := strings.Split(*rdfGzips, ",")
	for _, path := range files {
		if len(path) == 0 {
			continue
		}
		glog.WithField("path", path).Info("Handling...")
		f, err := os.Open(path)
		if err != nil {
			glog.WithError(err).Fatal("Unable to open rdf file.")
		}

		r, err := gzip.NewReader(f)
		if err != nil {
			glog.WithError(err).Fatal("Unable to create gzip reader.")
		}

		count, err := HandleRdfReader(db, r, *mod)
		if err != nil {
			glog.WithError(err).Fatal("While handling rdf reader.")
		}
		glog.WithField("count", count).Info("RDFs parsed")

		r.Close()
		f.Close()
	}

	p := neoism.Props{"_xid_": 10}
	n, created, err := db.GetOrCreateNode("Entity", "_xid_", p)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Created", created)
	p, err = n.Properties()
	fmt.Println(n.Id(), p, err)
}
开发者ID:dgraph-io,项目名称:benchmarks,代码行数:54,代码来源:main.go


示例20: initdb

func initdb() {
	//neoism.Connect("http://username:[email protected]:port")
	var err error
	db, err = neoism.Connect("http://car_simulator:" + PASSWORD + "@carsimulator.sb05.stations.graphenedb.com:24789")
	//If error connecting to database, halt execution and display error message
	if err != nil {
		panic(err)
	}
	if db == nil {
		panic("Database object is null")
	}
}
开发者ID:SouthendDevs,项目名称:gsy,代码行数:12,代码来源:junctionQuery.go



注:本文中的github.com/jmcvetta/neoism.Connect函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang neoism.Database类代码示例发布时间:2022-05-23
下一篇:
Golang napping.Session类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap