GithubHelp home page GithubHelp logo

Comments (6)

Ranxy avatar Ranxy commented on May 29, 2024 3

@laura-ding Ok, I will then start the wrapped task.

from nebula-go.

everywan avatar everywan commented on May 29, 2024 1

Hi everyone, I have write a orm library support nebula write by go, now it's feature like this

  1. support insert Vertex/Edge use map or struct
  2. parse execute result to struct or map.
  3. will support chainable in the future

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

from nebula-go.

wey-gu avatar wey-gu commented on May 29, 2024

Thank you @Ranxy!
What do you think of this please? @Aiee @laura-ding

from nebula-go.

laura-ding avatar laura-ding commented on May 29, 2024

@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.

from nebula-go.

laura-ding avatar laura-ding commented on May 29, 2024

@laura-ding Ok, I will then start the wrapped task.

Thanks for your contribution.

from nebula-go.

wey-gu avatar wey-gu commented on May 29, 2024

@laura-ding Ok, I will then start the wrapped task.

Thank you @Ranxy!

from nebula-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.