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

Golang v2.DB函数代码示例

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

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



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

示例1: SetupTest

func (suite *TransformUnorderedMapSuite) SetupTest() {
	suite.T().Log("Setting up TransformUnorderedMapSuite")
	// Use imports to prevent errors
	_ = time.Time{}
	_ = compare.AnythingIsFine

	session, err := r.Connect(r.ConnectOpts{
		Address: url,
	})
	suite.Require().NoError(err, "Error returned when connecting to server")
	suite.session = session

	r.DBDrop("test").Exec(suite.session)
	err = r.DBCreate("test").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("test").Wait().Exec(suite.session)
	suite.Require().NoError(err)

	r.DB("test").TableDrop("even").Exec(suite.session)
	err = r.DB("test").TableCreate("even").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("test").Table("even").Wait().Exec(suite.session)
	suite.Require().NoError(err)
	r.DB("test").TableDrop("odd").Exec(suite.session)
	err = r.DB("test").TableCreate("odd").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("test").Table("odd").Wait().Exec(suite.session)
	suite.Require().NoError(err)
	r.DB("test").TableDrop("odd2").Exec(suite.session)
	err = r.DB("test").TableCreate("odd2").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("test").Table("odd2").Wait().Exec(suite.session)
	suite.Require().NoError(err)
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:34,代码来源:reql_transform_unordered_map_test.go


示例2: TearDownSuite

func (suite *MutationAtomicGetSetSuite) TearDownSuite() {
	suite.T().Log("Tearing down MutationAtomicGetSetSuite")

	if suite.session != nil {
		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
		r.DB("test").TableDrop("tbl").Exec(suite.session)
		r.DBDrop("test").Exec(suite.session)

		suite.session.Close()
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:11,代码来源:reql_mutation_atomic_get_set_test.go


示例3: TearDownSuite

func (suite *ChangefeedsIncludeStatesSuite) TearDownSuite() {
	suite.T().Log("Tearing down ChangefeedsIncludeStatesSuite")

	if suite.session != nil {
		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
		r.DB("test").TableDrop("tbl").Exec(suite.session)
		r.DBDrop("test").Exec(suite.session)

		suite.session.Close()
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:11,代码来源:reql_changefeeds_include_states_test.go


示例4: TearDownSuite

func (suite *PolymorphismSuite) TearDownSuite() {
	suite.T().Log("Tearing down PolymorphismSuite")

	if suite.session != nil {
		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
		r.DB("test").TableDrop("tbl").Exec(suite.session)
		r.DBDrop("test").Exec(suite.session)

		suite.session.Close()
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:11,代码来源:reql_polymorphism_test.go


示例5: TearDownSuite

func (suite *SindexNullsinstringsSuite) TearDownSuite() {
	suite.T().Log("Tearing down SindexNullsinstringsSuite")

	if suite.session != nil {
		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
		r.DB("test").TableDrop("tbl").Exec(suite.session)
		r.DBDrop("test").Exec(suite.session)

		suite.session.Close()
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:11,代码来源:reql_sindex_nullsinstrings_test.go


示例6: TearDownSuite

func (suite *TransformUnorderedMapSuite) TearDownSuite() {
	suite.T().Log("Tearing down TransformUnorderedMapSuite")

	if suite.session != nil {
		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
		r.DB("test").TableDrop("even").Exec(suite.session)
		r.DB("test").TableDrop("odd").Exec(suite.session)
		r.DB("test").TableDrop("odd2").Exec(suite.session)
		r.DBDrop("test").Exec(suite.session)

		suite.session.Close()
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:13,代码来源:reql_transform_unordered_map_test.go


示例7: createDBAndTables

func createDBAndTables() {
	r.DBCreate("SpottedWays").Run(Sess)
	r.DB("SpottedWays").TableCreate("users").Run(Sess)
	r.DB("SpottedWays").TableCreate("places").Run(Sess)
	r.DB("SpottedWays").TableCreate("posts").Run(Sess)
	r.DB("SpottedWays").TableCreate("likes").Run(Sess)
	r.DB("SpottedWays").TableCreate("talks").Run(Sess)
	r.DB("SpottedWays").TableCreate("matchs").Run(Sess)
	r.DB("SpottedWays").TableCreate("notifications").Run(Sess)
	r.DB("SpottedWays").TableCreate("history").Run(Sess)
	r.DB("SpottedWays").TableCreate("messages").Run(Sess)
}
开发者ID:Fantasim,项目名称:Langage-Go,代码行数:12,代码来源:api.go


示例8: createDbAndTables

func createDbAndTables() {

	//On creer la db Todolist si elle n'existe pas. (si elle existe deja, rien n'est fait)
	r.DBCreate("Todolist").Run(session)

	//On creer la table Todos si elle n'existe pas dans la db Todolist (si elle existe deja, rien n'est fait)
	r.DB("Todolist").TableCreate("Todos").Run(session)
}
开发者ID:Fantasim,项目名称:Langage-Go,代码行数:8,代码来源:main.go


示例9: TearDownSuite

func (suite *MathLogicLogicSuite) TearDownSuite() {
	suite.T().Log("Tearing down MathLogicLogicSuite")

	if suite.session != nil {
		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
		r.DBDrop("test").Exec(suite.session)

		suite.session.Close()
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:10,代码来源:reql_math_logic_logic_test.go


示例10: TearDownSuite

func (suite *GeoIntersectionInclusionSuite) TearDownSuite() {
	suite.T().Log("Tearing down GeoIntersectionInclusionSuite")

	if suite.session != nil {
		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
		r.DBDrop("test").Exec(suite.session)

		suite.session.Close()
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:10,代码来源:reql_geo_intersection_inclusion_test.go


示例11: consulta

func consulta(id int) {
	res, err := r.DB("test").Table("prueba").Get(id).Run(conn)
	if err != nil {
		fmt.Println("no hay datos")
	}
	fmt.Println("hay muchos datos")
	res.One(&row)
	if res.Err() != nil {
	}
	defer res.Close()
}
开发者ID:kar004,项目名称:proyectoX,代码行数:11,代码来源:main.go


示例12: initdb

func (m DefaultManager) initdb() {
	// create tables if needed
	tables := []string{tblNameConfig, tblNameEvents, tblNameAccounts, tblNameRoles, tblNameConsole, tblNameServiceKeys, tblNameRegistries, tblNameExtensions, tblNameWebhookKeys}
	for _, tbl := range tables {
		_, err := r.Table(tbl).Run(m.session)
		if err != nil {
			if _, err := r.DB(m.database).TableCreate(tbl).Run(m.session); err != nil {
				log.Fatalf("error creating table: %s", err)
			}
		}
	}
}
开发者ID:XuesongYang,项目名称:shipyard,代码行数:12,代码来源:manager.go


示例13: TestCases

func (suite *MetaCompositeSuite) TestCases() {
	suite.T().Log("Running MetaCompositeSuite: Tests meta operations in composite queries")

	{
		// meta/composite.py.yaml line #4
		/* ({'dbs_created':3,'config_changes':arrlen(3)}) */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dbs_created": 3, "config_changes": arrlen(3)}
		/* r.expr([1,2,3]).for_each(r.db_create('db_' + r.row.coerce_to('string'))) */

		suite.T().Log("About to run line #4: r.Expr([]interface{}{1, 2, 3}).ForEach(r.DBCreate(r.Add('db_', r.Row.CoerceTo('string'))))")

		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(r.DBCreate(r.Add("db_", r.Row.CoerceTo("string")))), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #4")
	}

	{
		// meta/composite.py.yaml line #8
		/* partial({'tables_created':9}) */
		var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 9})
		/* r.db_list().set_difference(["rethinkdb", "test"]).for_each(lambda db_name:
		r.expr([1,2,3]).for_each(lambda i:
		r.db(db_name).table_create('tbl_' + i.coerce_to('string')))) */

		suite.T().Log("About to run line #8: r.DBList().SetDifference([]interface{}{'rethinkdb', 'test'}).ForEach(func(db_name r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3}).ForEach(func(i r.Term) interface{} { return r.DB(db_name).TableCreate(r.Add('tbl_', i.CoerceTo('string')))})})")

		runAndAssert(suite.Suite, expected_, r.DBList().SetDifference([]interface{}{"rethinkdb", "test"}).ForEach(func(db_name r.Term) interface{} {
			return r.Expr([]interface{}{1, 2, 3}).ForEach(func(i r.Term) interface{} { return r.DB(db_name).TableCreate(r.Add("tbl_", i.CoerceTo("string"))) })
		}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #8")
	}

	{
		// meta/composite.py.yaml line #13
		/* partial({'dbs_dropped':3,'tables_dropped':9}) */
		var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 3, "tables_dropped": 9})
		/* r.db_list().set_difference(["rethinkdb", "test"]).for_each(r.db_drop(r.row)) */

		suite.T().Log("About to run line #13: r.DBList().SetDifference([]interface{}{'rethinkdb', 'test'}).ForEach(r.DBDrop(r.Row))")

		runAndAssert(suite.Suite, expected_, r.DBList().SetDifference([]interface{}{"rethinkdb", "test"}).ForEach(r.DBDrop(r.Row)), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #13")
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:52,代码来源:reql_meta_composite_test.go


示例14: max

func max() int {
	res, err := r.DB("test").Table("prueba").Max().Run(conn)
	if err != nil {
		fmt.Println("no hay datos")
		return 1
	}
	fmt.Println("hay muchos datos")
	var row map[string]interface{}
	res.One(&row)
	max := row["id"].(float64)
	b := int(max)
	b++
	return b
}
开发者ID:kar004,项目名称:proyectoX,代码行数:14,代码来源:main.go


示例15: TearDownSuite

func (suite *JoinsSuite) TearDownSuite() {
	suite.T().Log("Tearing down JoinsSuite")

	if suite.session != nil {
		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
		r.DB("test").TableDrop("messages").Exec(suite.session)
		r.DB("test").TableDrop("otbl").Exec(suite.session)
		r.DB("test").TableDrop("otbl2").Exec(suite.session)
		r.DB("test").TableDrop("receivers").Exec(suite.session)
		r.DB("test").TableDrop("senders").Exec(suite.session)
		r.DB("test").TableDrop("tbl").Exec(suite.session)
		r.DB("test").TableDrop("tbl2").Exec(suite.session)
		r.DBDrop("test").Exec(suite.session)

		suite.session.Close()
	}
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:17,代码来源:reql_joins_test.go


示例16: SetupTest

func (suite *ChangefeedsIncludeStatesSuite) SetupTest() {
	suite.T().Log("Setting up ChangefeedsIncludeStatesSuite")
	// Use imports to prevent errors
	_ = time.Time{}
	_ = compare.AnythingIsFine

	session, err := r.Connect(r.ConnectOpts{
		Address: url,
	})
	suite.Require().NoError(err, "Error returned when connecting to server")
	suite.session = session

	r.DBDrop("test").Exec(suite.session)
	err = r.DBCreate("test").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("test").Wait().Exec(suite.session)
	suite.Require().NoError(err)

	r.DB("test").TableDrop("tbl").Exec(suite.session)
	err = r.DB("test").TableCreate("tbl").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("test").Table("tbl").Wait().Exec(suite.session)
	suite.Require().NoError(err)
}
开发者ID:freedmand,项目名称:doc.vu,代码行数:24,代码来源:reql_changefeeds_include_states_test.go


示例17: SetupTest

func (suite *MathLogicFloorCeilRoundSuite) SetupTest() {
	suite.T().Log("Setting up MathLogicFloorCeilRoundSuite")
	// Use imports to prevent errors
	_ = time.Time{}
	_ = compare.AnythingIsFine

	session, err := r.Connect(r.ConnectOpts{
		Address: url,
	})
	suite.Require().NoError(err, "Error returned when connecting to server")
	suite.session = session

	r.DBDrop("test").Exec(suite.session)
	err = r.DBCreate("test").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("test").Wait().Exec(suite.session)
	suite.Require().NoError(err)

}
开发者ID:freedmand,项目名称:doc.vu,代码行数:19,代码来源:reql_math_logic_floor_ceil_round_test.go


示例18: TestCases

func (suite *TransformUnorderedMapSuite) TestCases() {
	suite.T().Log("Running TransformUnorderedMapSuite: Tests for ordered_union")

	even := r.DB("test").Table("even")
	_ = even // Prevent any noused variable errors
	odd := r.DB("test").Table("odd")
	_ = odd // Prevent any noused variable errors
	odd2 := r.DB("test").Table("odd2")
	_ = odd2 // Prevent any noused variable errors

	{
		// transform/unordered_map.yaml line #6
		/* AnythingIsFine */
		var expected_ string = compare.AnythingIsFine
		/* odd.insert([{"id":1, "num":1}, {"id":3, "num":3}, {"id":5, "num":5}]) */

		suite.T().Log("About to run line #6: odd.Insert([]interface{}{map[interface{}]interface{}{'id': 1, 'num': 1, }, map[interface{}]interface{}{'id': 3, 'num': 3, }, map[interface{}]interface{}{'id': 5, 'num': 5, }})")

		runAndAssert(suite.Suite, expected_, odd.Insert([]interface{}{map[interface{}]interface{}{"id": 1, "num": 1}, map[interface{}]interface{}{"id": 3, "num": 3}, map[interface{}]interface{}{"id": 5, "num": 5}}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #6")
	}

	{
		// transform/unordered_map.yaml line #7
		/* AnythingIsFine */
		var expected_ string = compare.AnythingIsFine
		/* even.insert([{"id":2, "num":2}, {"id":4, "num":4}, {"id":6, "num":6}]) */

		suite.T().Log("About to run line #7: even.Insert([]interface{}{map[interface{}]interface{}{'id': 2, 'num': 2, }, map[interface{}]interface{}{'id': 4, 'num': 4, }, map[interface{}]interface{}{'id': 6, 'num': 6, }})")

		runAndAssert(suite.Suite, expected_, even.Insert([]interface{}{map[interface{}]interface{}{"id": 2, "num": 2}, map[interface{}]interface{}{"id": 4, "num": 4}, map[interface{}]interface{}{"id": 6, "num": 6}}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #7")
	}

	{
		// transform/unordered_map.yaml line #8
		/* AnythingIsFine */
		var expected_ string = compare.AnythingIsFine
		/* odd2.insert([{"id":7, "num":1}, {"id":8, "num":3}, {"id":9, "num":2}]) */

		suite.T().Log("About to run line #8: odd2.Insert([]interface{}{map[interface{}]interface{}{'id': 7, 'num': 1, }, map[interface{}]interface{}{'id': 8, 'num': 3, }, map[interface{}]interface{}{'id': 9, 'num': 2, }})")

		runAndAssert(suite.Suite, expected_, odd2.Insert([]interface{}{map[interface{}]interface{}{"id": 7, "num": 1}, map[interface{}]interface{}{"id": 8, "num": 3}, map[interface{}]interface{}{"id": 9, "num": 2}}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #8")
	}

	{
		// transform/unordered_map.yaml line #11
		/* [{"id":1, "num":1}, {"id":3, "num":3}, {"id":5, "num":5}, {"id":2, "num":2}, {"id":4, "num":4}, {"id":6, "num":6}] */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 1, "num": 1}, map[interface{}]interface{}{"id": 3, "num": 3}, map[interface{}]interface{}{"id": 5, "num": 5}, map[interface{}]interface{}{"id": 2, "num": 2}, map[interface{}]interface{}{"id": 4, "num": 4}, map[interface{}]interface{}{"id": 6, "num": 6}}
		/* odd.order_by("num").union(even.order_by("num"), interleave = false) */

		suite.T().Log("About to run line #11: odd.OrderBy('num').Union(even.OrderBy('num')).OptArgs(r.UnionOpts{Interleave: false, })")

		runAndAssert(suite.Suite, expected_, odd.OrderBy("num").Union(even.OrderBy("num")).OptArgs(r.UnionOpts{Interleave: false}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #11")
	}

	{
		// transform/unordered_map.yaml line #16
		/* [{"id":2, "num":2}, {"id":4, "num":4}, {"id":6, "num":6}, {"id":1, "num":1}, {"id":3, "num":3}, {"id":5, "num":5}] */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 2, "num": 2}, map[interface{}]interface{}{"id": 4, "num": 4}, map[interface{}]interface{}{"id": 6, "num": 6}, map[interface{}]interface{}{"id": 1, "num": 1}, map[interface{}]interface{}{"id": 3, "num": 3}, map[interface{}]interface{}{"id": 5, "num": 5}}
		/* even.order_by("num").union(odd.order_by("num"), interleave = false) */

		suite.T().Log("About to run line #16: even.OrderBy('num').Union(odd.OrderBy('num')).OptArgs(r.UnionOpts{Interleave: false, })")

		runAndAssert(suite.Suite, expected_, even.OrderBy("num").Union(odd.OrderBy("num")).OptArgs(r.UnionOpts{Interleave: false}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #16")
	}

	{
		// transform/unordered_map.yaml line #22
		/* [{"id":1, "num":1}, {"id":2, "num":2}, {"id":3, "num":3}, {"id":4, "num":4}, {"id":5, "num":5}, {"id":6, "num":6}] */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 1, "num": 1}, map[interface{}]interface{}{"id": 2, "num": 2}, map[interface{}]interface{}{"id": 3, "num": 3}, map[interface{}]interface{}{"id": 4, "num": 4}, map[interface{}]interface{}{"id": 5, "num": 5}, map[interface{}]interface{}{"id": 6, "num": 6}}
		/* odd.order_by("num").union(even.order_by("num"), interleave="num") */

		suite.T().Log("About to run line #22: odd.OrderBy('num').Union(even.OrderBy('num')).OptArgs(r.UnionOpts{Interleave: 'num', })")

		runAndAssert(suite.Suite, expected_, odd.OrderBy("num").Union(even.OrderBy("num")).OptArgs(r.UnionOpts{Interleave: "num"}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #22")
	}

//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_transform_unordered_map_test.go


示例19: TestCases

func (suite *ChangefeedsIncludeStatesSuite) TestCases() {
	suite.T().Log("Running ChangefeedsIncludeStatesSuite: Test `include_states`")

	tbl := r.DB("test").Table("tbl")
	_ = tbl // Prevent any noused variable errors

	{
		// changefeeds/include_states.yaml line #4
		/* [{'state':'ready'}] */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "ready"}}
		/* tbl.changes(squash=true, include_states=true).limit(1) */

		suite.T().Log("About to run line #4: tbl.Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, }).Limit(1)")

		runAndAssert(suite.Suite, expected_, tbl.Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true}).Limit(1), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #4")
	}

	{
		// changefeeds/include_states.yaml line #9
		/* [{'state':'initializing'}, {'new_val':null}, {'state':'ready'}] */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "initializing"}, map[interface{}]interface{}{"new_val": nil}, map[interface{}]interface{}{"state": "ready"}}
		/* tbl.get(0).changes(squash=true, include_states=true, include_initial=true).limit(3) */

		suite.T().Log("About to run line #9: tbl.Get(0).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true, }).Limit(3)")

		runAndAssert(suite.Suite, expected_, tbl.Get(0).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true}).Limit(3), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #9")
	}

	{
		// changefeeds/include_states.yaml line #14
		/* [{'state':'initializing'}, {'state':'ready'}] */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "initializing"}, map[interface{}]interface{}{"state": "ready"}}
		/* tbl.order_by(index='id').limit(10).changes(squash=true, include_states=true, include_initial=true).limit(2) */

		suite.T().Log("About to run line #14: tbl.OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true, }).Limit(2)")

		runAndAssert(suite.Suite, expected_, tbl.OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true}).Limit(2), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #14")
	}

	{
		// changefeeds/include_states.yaml line #19
		/* AnythingIsFine */
		var expected_ string = compare.AnythingIsFine
		/* tbl.insert({'id':1}) */

		suite.T().Log("About to run line #19: tbl.Insert(map[interface{}]interface{}{'id': 1, })")

		runAndAssert(suite.Suite, expected_, tbl.Insert(map[interface{}]interface{}{"id": 1}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #19")
	}

	{
		// changefeeds/include_states.yaml line #21
		/* [{'state':'initializing'}, {'new_val':{'id':1}}, {'state':'ready'}] */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "initializing"}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"state": "ready"}}
		/* tbl.order_by(index='id').limit(10).changes(squash=true, include_states=true, include_initial=true).limit(3) */

		suite.T().Log("About to run line #21: tbl.OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true, }).Limit(3)")

		runAndAssert(suite.Suite, expected_, tbl.OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true}).Limit(3), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #21")
	}

	// changefeeds/include_states.yaml line #26
	// tblchanges = tbl.changes(squash=true, include_states=true)
	suite.T().Log("Possibly executing: var tblchanges r.Term = tbl.Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, })")

	tblchanges := maybeRun(tbl.Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true}), suite.session, r.RunOpts{})
	_ = tblchanges // Prevent any noused variable errors

	{
		// changefeeds/include_states.yaml line #30
		/* AnythingIsFine */
		var expected_ string = compare.AnythingIsFine
		/* tbl.insert({'id':2}) */

		suite.T().Log("About to run line #30: tbl.Insert(map[interface{}]interface{}{'id': 2, })")

		runAndAssert(suite.Suite, expected_, tbl.Insert(map[interface{}]interface{}{"id": 2}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_changefeeds_include_states_test.go


示例20: TestCases

func (suite *MutationSyncSuite) TestCases() {
	suite.T().Log("Running MutationSyncSuite: Tests syncing tables")

	{
		// mutation/sync.yaml line #5
		/* partial({'tables_created':1}) */
		var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1})
		/* r.db('test').table_create('test1') */

		suite.T().Log("About to run line #5: r.DB('test').TableCreate('test1')")

		runAndAssert(suite.Suite, expected_, r.DB("test").TableCreate("test1"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #5")
	}

	{
		// mutation/sync.yaml line #7
		/* partial({'tables_created':1}) */
		var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1})
		/* r.db('test').table_create('test1soft') */

		suite.T().Log("About to run line #7: r.DB('test').TableCreate('test1soft')")

		runAndAssert(suite.Suite, expected_, r.DB("test").TableCreate("test1soft"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #7")
	}

	{
		// mutation/sync.yaml line #9
		/* {'skipped':0, 'deleted':0, 'unchanged':0, 'errors':0, 'replaced':1, 'inserted':0} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"skipped": 0, "deleted": 0, "unchanged": 0, "errors": 0, "replaced": 1, "inserted": 0}
		/* r.db('test').table('test1soft').config().update({'durability':'soft'}) */

		suite.T().Log("About to run line #9: r.DB('test').Table('test1soft').Config().Update(map[interface{}]interface{}{'durability': 'soft', })")

		runAndAssert(suite.Suite, expected_, r.DB("test").Table("test1soft").Config().Update(map[interface{}]interface{}{"durability": "soft"}), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #9")
	}

	// mutation/sync.yaml line #11
	// tbl = r.db('test').table('test1')
	suite.T().Log("Possibly executing: var tbl r.Term = r.DB('test').Table('test1')")

	tbl := r.DB("test").Table("test1")
	_ = tbl // Prevent any noused variable errors

	// mutation/sync.yaml line #12
	// tbl_soft = r.db('test').table('test1soft')
	suite.T().Log("Possibly executing: var tbl_soft r.Term = r.DB('test').Table('test1soft')")

	tbl_soft := r.DB("test").Table("test1soft")
	_ = tbl_soft // Prevent any noused variable errors

	{
		// mutation/sync.yaml line #13
		/* partial({'created':1}) */
		var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"created": 1})
		/* tbl.index_create('x') */

		suite.T().Log("About to run line #13: tbl.IndexCreate('x')")

		runAndAssert(suite.Suite, expected_, tbl.IndexCreate("x"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #13")
	}

	{
		// mutation/sync.yaml line #15
		/* [{'ready':True, 'index':'x'}] */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"ready": true, "index": "x"}}
		/* tbl.index_wait('x').pluck('index', 'ready') */

		suite.T().Log("About to run line #15: tbl.IndexWait('x').Pluck('index', 'ready')")

		runAndAssert(suite.Suite, expected_, tbl.IndexWait("x").Pluck("index", "ready"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #15")
	}

	{
		// mutation/sync.yaml line #19
		/* {'synced':1} */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"synced": 1}
		/* tbl.sync() */

		suite.T().Log("About to run line #19: tbl.Sync()")

//.........这里部分代码省略.........
开发者ID:freedmand,项目名称:doc.vu,代码行数:101,代码来源:reql_mutation_sync_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang v2.DBCreate函数代码示例发布时间:2022-05-28
下一篇:
Golang v2.Connect函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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