🎨 Used table name constant for topic sqlite repository queries
This commit is contained in:
parent
0828c0783a
commit
75e192d526
|
@ -44,24 +44,25 @@ type (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
queryTable string = `CREATE TABLE IF NOT EXISTS topics (
|
table string = "topics"
|
||||||
|
queryTable string = `CREATE TABLE IF NOT EXISTS ` + table + ` (
|
||||||
created_at DATETIME,
|
created_at DATETIME,
|
||||||
updated_at DATETIME,
|
updated_at DATETIME,
|
||||||
url TEXT PRIMARY KEY,
|
url TEXT PRIMARY KEY,
|
||||||
content_type TEXT,
|
content_type TEXT,
|
||||||
content BLOB
|
content BLOB
|
||||||
)`
|
)`
|
||||||
queryIndex string = `CREATE INDEX urls ON topics (url);`
|
queryIndex string = `CREATE INDEX urls ON ` + table + ` (url);`
|
||||||
queryCreate string = `INSERT INTO topics (created_at, updated_at, url, content_type, content)
|
queryCreate string = `INSERT INTO ` + table + ` (created_at, updated_at, url, content_type, content)
|
||||||
VALUES (:created_at, :updated_at, :url, :content_type, :content);`
|
VALUES (:created_at, :updated_at, :url, :content_type, :content);`
|
||||||
queryFetch string = `SELECT * FROM topics;`
|
queryFetch string = `SELECT * FROM ` + table + `;`
|
||||||
queryRead string = `SELECT * FROM topics WHERE url = ?;`
|
queryRead string = `SELECT * FROM ` + table + ` WHERE url = ?;`
|
||||||
queryUpdate string = `UPDATE topics
|
queryUpdate string = `UPDATE ` + table + `
|
||||||
SET updated_at = :updated_at,
|
SET updated_at = :updated_at,
|
||||||
content_type = :content_type,
|
content_type = :content_type,
|
||||||
content = :content
|
content = :content
|
||||||
WHERE url = :url;`
|
WHERE url = :url;`
|
||||||
queryDelete string = `DELETE FROM topics WHERE url = ?;`
|
queryDelete string = `DELETE FROM ` + table + ` WHERE url = ?;`
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewSQLiteTopicRepository(db *sqlx.DB) (topic.Repository, error) {
|
func NewSQLiteTopicRepository(db *sqlx.DB) (topic.Repository, error) {
|
||||||
|
|
Loading…
Reference in New Issue