Stores ID data in the database. @params: twitterID, blueskyID, dateCreated, reposterDid @results: error
(twitterID *int64, blueskyId string, dateCreated *time.Time, reposterDid *string)
| 366 | // @params: twitterID, blueskyID, dateCreated, reposterDid |
| 367 | // @results: error |
| 368 | func StoreTwitterIdInDatabase(twitterID *int64, blueskyId string, dateCreated *time.Time, reposterDid *string) error { |
| 369 | if twitterID == nil { |
| 370 | return fmt.Errorf("twitterID is nil") |
| 371 | } |
| 372 | |
| 373 | storedData := TwitterIDs{ |
| 374 | TwitterID: strconv.FormatInt(*twitterID, 10), // Convert *int64 to string |
| 375 | BlueskyID: blueskyId, |
| 376 | DateCreated: dateCreated, |
| 377 | ReposterDid: reposterDid, |
| 378 | } |
| 379 | |
| 380 | result := db.Clauses(clause.OnConflict{ |
| 381 | Columns: []clause.Column{ |
| 382 | {Name: "twitter_id"}, |
| 383 | }, |
| 384 | UpdateAll: true, |
| 385 | }).Create(&storedData) |
| 386 | |
| 387 | if result.Error != nil { |
| 388 | // If there's an error, try updating the existing record |
| 389 | fmt.Println("Error:", result.Error) |
| 390 | panic(result.Error) |
| 391 | //return db.Model(&TwitterIDs{}).Where("twitter_id = ?", strconv.FormatUint(twitterID, 10)).Updates(storedData).Error |
| 392 | } |
| 393 | |
| 394 | return nil |
| 395 | } |
| 396 | |
| 397 | // Gets a twitter id from the database |
| 398 | // @params: twitterID |
no outgoing calls
no test coverage detected