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

Golang mongo.ConnectionFactory类代码示例

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

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



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

示例1: UpdateAll3

func (c ResumeTest) UpdateAll3() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}
	txnId := txnManager.BeginTransaction()

	query := map[string]interface{}{
		"_id": map[string]interface{}{
			"$lte": 100,
		},
	}
	update := map[string]interface{}{
		"$inc": map[string]interface{}{
			"age": 5,
		},
	}
	unModify := map[string]interface{}{
		"$inc": map[string]interface{}{
			"age": -5,
		},
	}
	obj, _ := txnManager.UpdateAll(txnId, "Test1", query, update, unModify)
	fmt.Println("obj3", obj)
	txnManager.Commit(txnId)

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("UpdateAll3")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:30,代码来源:resumetest.go


示例2: RecoverTest

func (c ResumeTest) RecoverTest() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}

	txnId := txnManager.BeginTransaction()
	defer func() {
		if x := recover(); x != nil {
			txnManager.Rollback(txnId)
			panic(x)
		}
	}()

	test1 := map[string]interface{}{"name": "insertTest1"}
	txnManager.Insert(txnId, "Test1", test1)
	test2 := map[string]interface{}{"name": "insertTest2"}
	txnManager.Insert(txnId, "Test2", test2)

	txnManager.Commit(txnId)

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("Commit1")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:25,代码来源:resumetest.go


示例3: Commit9

func (c ResumeTest) Commit9() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}

	txnId := txnManager.BeginTransaction()

	test1 := map[string]interface{}{"name": "insertTest9"}
	txnManager.Insert(txnId, "Test1", test1)

	test3 := map[string]interface{}{"_id": 3, "name": "insertTest9"}
	txnManager.Remove(txnId, "Test2", test3)

	test2 := map[string]interface{}{"_id": 4, "name": "insertTest9"}
	txnManager.Update(txnId, "Test2", test2)

	test4 := map[string]interface{}{"_id": 5, "name": "insertTest9"}
	txnManager.Remove(txnId, "Test2", test4)

	txnManager.Commit(txnId)

	c.Response.ContentType = "text/plain; charset=utf-9"
	return c.RenderText("Commit9")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:26,代码来源:resumetest.go


示例4: UpdateAll1

func (c ResumeTest) UpdateAll1() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}
	txnId := txnManager.BeginTransaction()

	query := map[string]interface{}{
		"_id": 36,
	}
	update := map[string]interface{}{
		"$set": map[string]interface{}{
			"age": 20,
		},
	}
	unModify := map[string]interface{}{
		"$unset": map[string]interface{}{
			"age": 1,
		},
	}
	txnManager.UpdateAll(txnId, "Test1", query, update, unModify)
	txnManager.Commit(txnId)

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("UpdateAll1")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:27,代码来源:resumetest.go


示例5: ResumeBeginCommit2

func (c ResumeTest) ResumeBeginCommit2() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}
	txnManager.ResumePeriod()

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("ResumeBeginCommit2")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:11,代码来源:resumetest.go


示例6: BeginTransaction

func (c ModelTest) BeginTransaction() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}

	txnManager.BeginTransaction()

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("BeginTransaction")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:12,代码来源:sysuser.go


示例7: Commit12

func (c ModelTest) Commit12() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}

	txnId := txnManager.BeginTransaction()

	{
		query := map[string]interface{}{
			"_id": map[string]interface{}{
				"$lt": 7,
			},
		}
		update := map[string]interface{}{
			"$set": map[string]interface{}{
				"age": 9,
			},
		}
		unModify := map[string]interface{}{
			"$unset": map[string]interface{}{
				"age": 1,
			},
		}
		txnManager.UpdateAll(txnId, "Test1", query, update, unModify)
	}
	{
		query := map[string]interface{}{
			"_id": map[string]interface{}{
				"$gte": 8,
			},
		}
		update := map[string]interface{}{
			"$set": map[string]interface{}{
				"age": 9,
			},
		}
		unModify := map[string]interface{}{
			"$unset": map[string]interface{}{
				"age": 1,
			},
		}
		txnManager.UpdateAll(txnId, "Test2", query, update, unModify)
	}

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("Commit12")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:49,代码来源:sysuser.go


示例8: SelectForUpdate2

func (c ResumeTest) SelectForUpdate2() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}
	txnId := txnManager.BeginTransaction()

	test1 := map[string]interface{}{
		"_id":  36,
		"name": "SelectForUpdate2",
	}
	txnManager.SelectForUpdate(txnId, "Test1", test1)

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("SelectForUpdate2")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:17,代码来源:resumetest.go


示例9: Commit2

func (c ModelTest) Commit2() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}

	txnId := txnManager.BeginTransaction()

	test1 := map[string]interface{}{"name": "insertTest2"}
	txnManager.Insert(txnId, "Test1", test1)
	test2 := map[string]interface{}{"name": "insertTest2"}
	txnManager.Insert(txnId, "Test2", test2)

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("Commit2")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:17,代码来源:sysuser.go


示例10: RemoveAll1

func (c ResumeTest) RemoveAll1() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}
	txnId := txnManager.BeginTransaction()

	query := map[string]interface{}{
		"_id": 5,
	}
	obj, _ := txnManager.RemoveAll(txnId, "Test1", query)
	fmt.Println("removeAll1", obj)
	txnManager.Commit(txnId)

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("RemoveAll1")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:18,代码来源:resumetest.go


示例11: Commit20

func (c ResumeTest) Commit20() revel.Result {
	connectionFactory := mongo.ConnectionFactory{}
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	txnManager := TxnManager{db}
	txnId := txnManager.BeginTransaction()

	test1 := map[string]interface{}{
		"name": "insertTest20",
	}
	test1 = txnManager.Insert(txnId, "Test1", test1)
	test1["address"] = "xiamen"
	test1, _ = txnManager.Update(txnId, "Test1", test1)
	test1["age"] = 20
	test1, _ = txnManager.Update(txnId, "Test1", test1)

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText("Commit20")
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:20,代码来源:resumetest.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang common.CoerceValues函数代码示例发布时间:2022-05-24
下一篇:
Golang global.SetGlobalAttr函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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