當前位置: 首頁>>代碼示例>>Golang>>正文


Golang neoism.Connect函數代碼示例

本文整理匯總了Golang中github.com/jmcvetta/neoism.Connect函數的典型用法代碼示例。如果您正苦於以下問題:Golang Connect函數的具體用法?Golang Connect怎麽用?Golang Connect使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Connect函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/jmcvetta/neoism.Connect函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。