Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

update: seed data

boojackb1adaf9c4e6e
diff --git a/api/memo.go b/api/memo.go
index b71b95ee2..d5ba92904 100644
--- a/api/memo.go
+++ b/api/memo.go
@@ -1,31 +1,41 @@
package api
type Memo struct {
- ID int `json:"id"`
+ ID int `json:"id"`
+
+ // Standard fields
CreatedTs int64 `json:"createdTs"`
UpdatedTs int64 `json:"updatedTs"`
RowStatus string `json:"rowStatus"`
+ // Domain specific fields
Content string `json:"content"`
CreatorID int `json:"creatorId"`
}
type MemoCreate struct {
+ // Standard fields
CreatorID int
+ // Domain specific fields
Content string `json:"content"`
}
type MemoPatch struct {
ID int
- Content *string `json:"content"`
- RowStatus *string `json:"rowStatus"`
+ // Standard fields
CreatedTs *int64 `json:"createdTs"`
+ RowStatus *string `json:"rowStatus"`
+
+ // Domain specific fields
+ Content *string `json:"content"`
}
type MemoFind struct {
- ID *int `json:"id"`
+ ID *int `json:"id"`
+
+ // Standard fields
CreatorID *int `json:"creatorId"`
RowStatus *string `json:"rowStatus"`
}
diff --git a/api/resource.go b/api/resource.go
index b83434983..59a2ed301 100644
--- a/api/resource.go
+++ b/api/resource.go
@@ -1,31 +1,39 @@
package api
type Resource struct {
- ID int `json:"id"`
+ ID int `json:"id"`
+
+ // Standard fields
+ CreatorID int `json:"creatorId"`
CreatedTs int64 `json:"createdTs"`
UpdatedTs int64 `json:"updatedTs"`
+ // Domain specific fields
Filename string `json:"filename"`
Blob []byte `json:"blob"`
Type string `json:"type"`
Size int64 `json:"size"`
-
- CreatorID int `json:"creatorId"`
}
type ResourceCreate struct {
+ // Standard fields
+ CreatorID int
+
+ // Domain specific fields
Filename string `json:"filename"`
Blob []byte `json:"blob"`
Type string `json:"type"`
Size int64 `json:"size"`
-
- CreatorID int
}
type ResourceFind struct {
- ID *int `json:"id"`
- CreatorID *int `json:"creatorId"`
- Filename *string `json:"filename"`
+ ID *int `json:"id"`
+
+ // Standard fields
+ CreatorID *int `json:"creatorId"`
+
+ // Domain specific fields
+ Filename *string `json:"filename"`
}
type ResourceDelete struct {
diff --git a/api/shortcut.go b/api/shortcut.go
index 633cb1c35..305d4a184 100644
--- a/api/shortcut.go
+++ b/api/shortcut.go
@@ -1,14 +1,17 @@
package api
type Shortcut struct {
- ID int `json:"id"`
- CreatedTs int64 `json:"createdTs"`
- UpdatedTs int64 `json:"updatedTs"`
+ ID int `json:"id"`
- Title string `json:"title"`
- Payload string `json:"payload"`
- RowStatus string `json:"rowStatus"`
+ // Standard fields
CreatorID int
+ CreatedTs int64 `json:"createdTs"`
+ UpdatedTs int64 `json:"updatedTs"`
+ RowStatus string `json:"rowStatus"`
+
+ // Domain specific fields
+ Title string `json:"title"`
+ Payload string `json:"payload"`
}
type ShortcutCreate struct {
@@ -23,9 +26,12 @@ type ShortcutCreate struct {
type ShortcutPatch struct {
ID int
- Title *string `json:"title"`
- Payload *string `json:"payload"`
+ // Standard fields
RowStatus *string `json:"rowStatus"`
+
+ // Domain specific fields
+ Title *string `json:"title"`
+ Payload *string `json:"payload"`
}
type ShortcutFind struct {
diff --git a/api/user.go b/api/user.go
index da6b20e28..c7d0fbe56 100644
--- a/api/user.go
+++ b/api/user.go
@@ -1,16 +1,20 @@
package api
type User struct {
- ID int `json:"id"`
+ ID int `json:"id"`
+
+ // Standard fields
CreatedTs int64 `json:"createdTs"`
UpdatedTs int64 `json:"updatedTs"`
+ // Domain specific fields
OpenID string `json:"openId"`
Name string `json:"name"`
PasswordHash string `json:"-"`
}
type UserCreate struct {
+ // Domain specific fields
OpenID string
Name string
PasswordHash string
@@ -19,17 +23,18 @@ type UserCreate struct {
type UserPatch struct {
ID int
+ // Domain specific fields
OpenID *string
PasswordHash *string
-
- Name *string `json:"name"`
- Password *string `json:"password"`
- ResetOpenID *bool `json:"resetOpenId"`
+ Name *string `json:"name"`
+ Password *string `json:"password"`
+ ResetOpenID *bool `json:"resetOpenId"`
}
type UserFind struct {
ID *int `json:"id"`
+ // Domain specific fields
Name *string `json:"name"`
OpenID *string
}
diff --git a/store/migration/10001__schema.sql b/store/migration/10001__schema.sql
index cffe57d64..bf07cc5a9 100644
--- a/store/migration/10001__schema.sql
+++ b/store/migration/10001__schema.sql
@@ -62,7 +62,7 @@ CREATE TABLE shortcut (
updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
title TEXT NOT NULL DEFAULT '',
- payload TEXT NOT NULL DEFAULT '',
+ payload TEXT NOT NULL DEFAULT '{}',
creator_id INTEGER NOT NULL,
-- allowed row status are 'NORMAL', 'ARCHIVED'.
row_status TEXT NOT NULL DEFAULT 'NORMAL',
diff --git a/store/seed/10001__user.sql b/store/seed/10001__user.sql
index 94394e0e7..2d89d17f5 100644
--- a/store/seed/10001__user.sql
+++ b/store/seed/10001__user.sql
@@ -13,3 +13,19 @@ VALUES
-- "secret"
'$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK'
);
+
+INSERT INTO
+ user (
+ `id`,
+ `name`,
+ `open_id`,
+ `password_hash`
+ )
+VALUES
+ (
+ 102,
+ 'dear_musk',
+ 'guest_open_id',
+ -- "secret"
+ '$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK'
+ );
diff --git a/store/seed/10002__shortcut.sql b/store/seed/10002__shortcut.sql
new file mode 100644
index 000000000..57b3ab173
--- /dev/null
+++ b/store/seed/10002__shortcut.sql
@@ -0,0 +1,10 @@
+INSERT INTO
+ shortcut (
+ `title`,
+ `creator_id`
+ )
+VALUES
+ (
+ 'All my memos',
+ 101
+ );