Skip to content

Commit

Permalink
Added Save func for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
SariaAlam committed Oct 18, 2023
1 parent 3c162c4 commit 816b32c
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions internal/model/notifications.go
Original file line number Diff line number Diff line change
@@ -1 +1,69 @@
package model

import (
"github.com/SohelAhmedJoni/Awazz-Backend/internal/durable"
)

func (n *Notifications) SaveNotifications() error {
db, err := durable.CreateDatabase("Database/notifications")
if err != nil {
return err
}
defer db.Close()
str := `
CREATE TABLE IF NOT EXISTS Messages (
Title VARCHAR(128),
Body VARCHAR(128),
Source VARCHAR(128),
Image VARCHAR(128),
Sound VARCHAR(128),
Time TIMESTAMP,
Channel VARCHAR(128),
PriorityLevel INT,
ReadStatus bool,
Created TIMESTAMP)
`
_, err = db.Exec(str)
if err != nil {
return err
}
str2 := `
INSERT INTO Messages (Title,Body,Source,Image,Sound,Time,Channel,PriorityLevel,ReadStatus,Created) VALUES (?,?,?,?,?,?,?,?,?,?);
`
statement, err := db.Prepare(str2)
if err != nil {
return err
}
_, err = statement.Exec(n.Title, n.Body, n.Source, n.Image, n.Sound, n.Time, n.Channel, n.PriorityLevel, n.ReadStatus, n.Created)
if err != nil {
return err
}

return nil
}

/*func (n *Notifications) GetNotifications() error {
db, err := durable.CreateDatabase("Database/notifications")
if err != nil {
return err
}
defer db.Close()
return nil
}
func (n *Notifications) UpdateNotifications() error {
db, err := durable.CreateDatabase("Database/notifications")
if err != nil {
return err
}
defer db.Close()
return nil
}
func (n *Notifications) DeleteNotifications() error {
db, err := durable.CreateDatabase("Database/notifications")
if err != nil {
return err
}
defer db.Close()
return nil
}
*/

0 comments on commit 816b32c

Please sign in to comment.