vikunja-api/vendor/xorm.io/builder/builder_delete.go

28 lines
567 B
Go
Raw Permalink Normal View History

2018-06-10 11:11:41 +02:00
// Copyright 2016 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package builder
import (
"fmt"
)
2019-03-29 18:54:35 +01:00
// Delete creates a delete Builder
func Delete(conds ...Cond) *Builder {
builder := &Builder{cond: NewCond()}
return builder.Delete(conds...)
}
2018-06-10 11:11:41 +02:00
func (b *Builder) deleteWriteTo(w Writer) error {
2019-03-29 18:54:35 +01:00
if len(b.from) <= 0 {
return ErrNoTableName
2018-06-10 11:11:41 +02:00
}
2019-03-29 18:54:35 +01:00
if _, err := fmt.Fprintf(w, "DELETE FROM %s WHERE ", b.from); err != nil {
2018-06-10 11:11:41 +02:00
return err
}
return b.cond.WriteTo(w)
}