本文整理汇总了Golang中github.com/theduke/go-dukedb.Backend.FindOneBy方法的典型用法代码示例。如果您正苦于以下问题:Golang Backend.FindOneBy方法的具体用法?Golang Backend.FindOneBy怎么用?Golang Backend.FindOneBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/theduke/go-dukedb.Backend
的用法示例。
在下文中一共展示了Backend.FindOneBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestBackend
//.........这里部分代码省略.........
Expect(res[0]).To(Equal(&m))
Expect(res[1]).To(Equal(&m2))
})
It("Should .FindOne()", func() {
m := NewTestModel(1)
Expect(backend.Create(&m)).ToNot(HaveOccurred())
model, err := backend.FindOne("test_models", m.Id)
Expect(err).ToNot(HaveOccurred())
Expect(model).To(Equal(&m))
})
It("Should .FindOne() with target model", func() {
m := NewTestModel(1)
Expect(backend.Create(&m)).ToNot(HaveOccurred())
var model TestModel
_, err := backend.FindOne("test_models", m.Id, &model)
Expect(err).ToNot(HaveOccurred())
Expect(model).To(Equal(m))
})
It("Should .FindOne() with target model pointer", func() {
m := NewTestModel(1)
Expect(backend.Create(&m)).ToNot(HaveOccurred())
var model *TestModel
_, err := backend.FindOne("test_models", m.Id, &model)
Expect(err).ToNot(HaveOccurred())
Expect(model).To(Equal(&m))
})
It("Should .FindOneBy()", func() {
m := NewTestModel(1)
Expect(backend.Create(&m)).ToNot(HaveOccurred())
model, err := backend.FindOneBy("test_models", "id", m.Id)
Expect(err).ToNot(HaveOccurred())
Expect(model).To(Equal(&m))
})
It("Should .FindOneBy() with target model", func() {
m := NewTestModel(1)
Expect(backend.Create(&m)).ToNot(HaveOccurred())
var model TestModel
_, err := backend.FindOneBy("test_models", "id", m.Id, &model)
Expect(err).ToNot(HaveOccurred())
Expect(model).To(Equal(m))
})
It("Should .FindOneBy() with target model pointer", func() {
m := NewTestModel(1)
Expect(backend.Create(&m)).ToNot(HaveOccurred())
var model *TestModel
_, err := backend.FindOneBy("test_models", "id", m.Id, &model)
Expect(err).ToNot(HaveOccurred())
Expect(model).To(Equal(&m))
})
})
Describe("Relationships", func() {
BeforeEach(func() {