本文整理汇总了Golang中github.com/theduke/go-dukedb.Backend.Delete方法的典型用法代码示例。如果您正苦于以下问题:Golang Backend.Delete方法的具体用法?Golang Backend.Delete怎么用?Golang Backend.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/theduke/go-dukedb.Backend
的用法示例。
在下文中一共展示了Backend.Delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestBackend
func TestBackend(skipFlag *bool, backendBuilder func() (db.Backend, apperror.Error)) {
doSkip := false
var backend db.Backend
BeforeEach(func() {
if *skipFlag || doSkip {
Skip("Skipping due to previous error.")
}
var err apperror.Error
backend, err = backendBuilder()
Expect(err).ToNot(HaveOccurred())
backend.SetDebug(true)
backend.RegisterModel(&Tag{})
backend.RegisterModel(&Project{})
backend.RegisterModel(&Task{})
backend.RegisterModel(&File{})
backend.RegisterModel(&TestModel{})
backend.RegisterModel(&TestParent{})
backend.RegisterModel(&HooksModel{})
backend.RegisterModel(&ValidationsModel{})
backend.RegisterModel(&MarshalledModel{})
backend.Build()
})
It("Should drop all collections", func() {
doSkip = true
err := backend.DropAllCollections()
Expect(err).ToNot(HaveOccurred())
doSkip = false
})
It("Should create collections", func() {
doSkip = true
err := backend.CreateCollection(
"test_models",
"test_parents",
"hooks_models",
"validations_models",
"marshalled_models",
"tags",
"projects",
"tasks",
"files",
)
Expect(err).ToNot(HaveOccurred())
doSkip = false
})
It("Should count with zero entries", func() {
Expect(backend.Q("test_models").Count()).To(Equal(0))
})
It("Should insert and set Id, then FindOne()", func() {
testModel := NewTestModel(1)
testModel.Id = 0
err := backend.Create(&testModel)
Expect(err).ToNot(HaveOccurred())
Expect(testModel.Id).ToNot(Equal(0))
m, err := backend.FindOne("test_models", testModel.Id)
Expect(err).ToNot(HaveOccurred())
Expect(*m.(*TestModel)).To(Equal(testModel))
})
It("Should count with 1 entry", func() {
Expect(backend.Create(&Project{Name: "Test"})).ToNot(HaveOccurred())
Expect(backend.Q("projects").Count()).To(Equal(1))
})
It("Should update", func() {
// Persist model to update.
testModel := NewTestModel(2)
err := backend.Create(&testModel)
Expect(err).ToNot(HaveOccurred())
testModel.IntVal = 33
testModel.StrVal = "str33"
err = backend.Update(&testModel)
Expect(err).ToNot(HaveOccurred())
m, err := backend.FindOne("test_models", testModel.Id)
Expect(err).ToNot(HaveOccurred())
Expect(m).To(Equal(&testModel))
})
It("Should delete", func() {
// Persist model to update.
testModel := NewTestModel(3)
err := backend.Create(&testModel)
Expect(err).ToNot(HaveOccurred())
err = backend.Delete(&testModel)
Expect(err).ToNot(HaveOccurred())
m, err := backend.FindOne("test_models", testModel.Id)
//.........这里部分代码省略.........