Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-media-repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
matrix-media-repo
Commits
1f10816e
Commit
1f10816e
authored
7 years ago
by
Travis Ralston
Browse files
Options
Downloads
Patches
Plain Diff
Rename SynapseDatabase and make LocalMedia a reference
parent
548fee56
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/github.com/turt2live/matrix-media-repo/synapse/db.go
+7
-7
7 additions, 7 deletions
src/github.com/turt2live/matrix-media-repo/synapse/db.go
with
7 additions
and
7 deletions
src/github.com/turt2live/matrix-media-repo/synapse/db.go
+
7
−
7
View file @
1f10816e
...
...
@@ -8,7 +8,7 @@ import (
const
selectLocalMedia
=
"SELECT media_id, media_type, media_length, created_ts, upload_name, user_id FROM local_media_repository;"
type
Syn
apse
Database
struct
{
type
SynDatabase
struct
{
db
*
sql
.
DB
statements
statements
}
...
...
@@ -17,8 +17,8 @@ type statements struct {
selectLocalMedia
*
sql
.
Stmt
}
func
OpenDatabase
(
connectionString
string
)
(
*
Syn
apse
Database
,
error
)
{
var
d
Syn
apse
Database
func
OpenDatabase
(
connectionString
string
)
(
*
SynDatabase
,
error
)
{
var
d
SynDatabase
var
err
error
if
d
.
db
,
err
=
sql
.
Open
(
"postgres"
,
connectionString
);
err
!=
nil
{
...
...
@@ -32,16 +32,16 @@ func OpenDatabase(connectionString string) (*SynapseDatabase, error) {
return
&
d
,
nil
}
func
(
d
*
Syn
apse
Database
)
GetAllMedia
()
([]
LocalMedia
,
error
)
{
func
(
d
*
SynDatabase
)
GetAllMedia
()
([]
*
LocalMedia
,
error
)
{
rows
,
err
:=
d
.
statements
.
selectLocalMedia
.
Query
()
if
err
!=
nil
{
if
err
==
sql
.
ErrNoRows
{
return
[]
LocalMedia
{},
nil
// no records
return
[]
*
LocalMedia
{},
nil
// no records
}
return
nil
,
err
}
var
results
[]
LocalMedia
var
results
[]
*
LocalMedia
for
rows
.
Next
()
{
var
mediaId
sql
.
NullString
var
contentType
sql
.
NullString
...
...
@@ -60,7 +60,7 @@ func (d *SynapseDatabase) GetAllMedia() ([]LocalMedia, error) {
if
err
!=
nil
{
return
nil
,
err
}
results
=
append
(
results
,
LocalMedia
{
results
=
append
(
results
,
&
LocalMedia
{
MediaId
:
mediaId
.
String
,
ContentType
:
contentType
.
String
,
SizeBytes
:
sizeBytes
.
Int64
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment