Documentation ¶
Index ¶
- func ConnectDatabase(data Database) error
- func DisconnectDatabase(data Database) error
- type Database
- type File
- type MongoDB
- func (m *MongoDB) CheckUserAuth(user *User) (bool, error)
- func (m *MongoDB) CloseConnection() error
- func (m *MongoDB) GetAllFiles() (*[]File, error)
- func (m *MongoDB) GetAllNotes() (*[]Note, error)
- func (m *MongoDB) InitConnection() error
- func (m *MongoDB) InsertOneFile(file *File) error
- func (m *MongoDB) InsertOneNote(note *Note) error
- type MySQL
- func (m *MySQL) CheckUserAuth(user *User) (bool, error)
- func (m *MySQL) CloseConnection() error
- func (m *MySQL) GetAllFiles() (*[]File, error)
- func (m *MySQL) GetAllNotes() (*[]Note, error)
- func (m *MySQL) InitConnection() error
- func (m *MySQL) InsertOneFile(file *File) error
- func (m *MySQL) InsertOneNote(note *Note) error
- type Note
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectDatabase ¶
ConnectDatabase is function which load the database.
func DisconnectDatabase ¶
DisconnectDatabase is function which disconnect the database.
Types ¶
type Database ¶
type Database interface { // The init function of this database. InitConnection() error // The close function of this database. CloseConnection() error // Verify that the user information is reasonable. CheckUserAuth(user *User) (bool, error) // Insert one note to this labnote system. InsertOneNote(note *Note) error // Insert one file to this labnote system. InsertOneFile(file *File) error // Request all notes from the database. GetAllNotes() (*[]Note, error) // Request all files from the database. GetAllFiles() (*[]File, error) }
Database definition of the abstract interface of it.
type File ¶
type File struct { Time time.Time `bson:"time"` // upload time of file Name string `bson:"name"` // the name of this file Hash string `bson:"hash"` // the hash of file saved Url string `bson:"url"` // url of this file which is used to download }
File is a structure of server's files.
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
Here is the definition of the database structure.
func NewMongoDB ¶
func (*MongoDB) CheckUserAuth ¶
CheckUserAuth is a check of if user permissions are correct.
func (*MongoDB) CloseConnection ¶
CloseConnection is a function close the connection with mongodb.
func (*MongoDB) GetAllFiles ¶
GetAllFiles is used to return all of the files in storage.
func (*MongoDB) GetAllNotes ¶
GetAllNotes function return all the notes in the database.
func (*MongoDB) InitConnection ¶
InitConnection function initialize the connection to the database.
func (*MongoDB) InsertOneFile ¶
InsertOneFile insert a new file into the database's file collection.
func (*MongoDB) InsertOneNote ¶
InsertOneNote insert a new note into the database's note collection.
type MySQL ¶
type MySQL struct {
// contains filtered or unexported fields
}
Here is the definition of the database structure.
func (*MySQL) CheckUserAuth ¶
CheckUserAuth is a check of if user permissions are correct.
func (*MySQL) CloseConnection ¶
CloseConnection is a function close the connection with mongodb.
func (*MySQL) GetAllFiles ¶
GetAllFiles is used to return all of the files in storage.
func (*MySQL) GetAllNotes ¶
GetAllNotes function return all the notes in the database.
func (*MySQL) InitConnection ¶
InitConnection function initialize the connection to the database.
func (*MySQL) InsertOneFile ¶
InsertOneFile insert a new file into the database's file collection.
func (*MySQL) InsertOneNote ¶
InsertOneNote insert a new note into the database's note collection.