init
This commit is contained in:
commit
fa6a4c650f
93 files changed
+6555
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (s *Store) CreateObject(
|
||||
path string,
|
||||
) (string, error) {
|
||||
|
||||
objectUUID :=
|
||||
uuid.NewString()
|
||||
|
||||
_, err := s.DB.Exec(`
|
||||
INSERT INTO objects (
|
||||
uuid,
|
||||
created_at
|
||||
)
|
||||
VALUES (
|
||||
?,
|
||||
strftime('%s','now')
|
||||
)
|
||||
`,
|
||||
objectUUID,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
_, err = s.DB.Exec(`
|
||||
INSERT INTO paths (
|
||||
path,
|
||||
object_uuid,
|
||||
created_at
|
||||
)
|
||||
VALUES (
|
||||
?, ?,
|
||||
strftime('%s','now')
|
||||
)
|
||||
`,
|
||||
path,
|
||||
objectUUID,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return objectUUID, nil
|
||||
}
|
||||
Reference in new issue
Block a user