MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Insert

Method Insert

models/book.go:146–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144}
145
146func (m *Book) Insert() (err error) {
147 o := orm.NewOrm()
148 if _, err = o.Insert(m); err != nil {
149 return
150 }
151
152 if m.Label != "" {
153 NewLabel().InsertOrUpdateMulti(m.Label)
154 }
155
156 relationship := NewRelationship()
157 relationship.BookId = m.BookId
158 relationship.RoleId = 0
159 relationship.MemberId = m.MemberId
160
161 if err = relationship.Insert(); err != nil {
162 logs.Error("插入书籍与用户关联 => ", err)
163 return err
164 }
165
166 document := NewDocument()
167 document.BookId = m.BookId
168 document.DocumentName = "空白文档"
169 document.Identify = "blank"
170 document.MemberId = m.MemberId
171
172 var id int64
173 if id, err = document.InsertOrUpdate(); err == nil {
174 var ds = DocumentStore{
175 DocumentId: int(id),
176 Markdown: "[TOC]\n\r\n\r", //默认内容
177 }
178 err = new(DocumentStore).InsertOrUpdate(ds)
179 }
180 return err
181}
182
183func (m *Book) Find(id int, cols ...string) (book *Book, err error) {
184 if id <= 0 {

Callers 3

CreateMethod · 0.95
initializationFunction · 0.95
CopyMethod · 0.45

Calls 7

InsertMethod · 0.95
InsertOrUpdateMethod · 0.95
NewLabelFunction · 0.85
NewRelationshipFunction · 0.85
NewDocumentFunction · 0.85
InsertOrUpdateMultiMethod · 0.80
InsertOrUpdateMethod · 0.45

Tested by

no test coverage detected