go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/chirp/pkg/model/chirp.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package model
     9  
    10  import (
    11  	"time"
    12  
    13  	"go.charczuk.com/sdk/uuid"
    14  )
    15  
    16  // Chirp is the main primitive of the app.
    17  //
    18  // It is either a text post, a rechirp, and can include attachments.
    19  type Chirp struct {
    20  	ID           uuid.UUID         `db:"id,pk,auto"`
    21  	UserID       uuid.UUID         `db:"user_id"`
    22  	CreatedUTC   time.Time         `db:"created_utc"`
    23  	PublishedUTC *time.Time        `db:"published_utc"`
    24  	Text         string            `db:"text"`
    25  	ReplyID      *uuid.UUID        `db:"reply_id"`
    26  	QuotedID     *uuid.UUID        `db:"quoted_id"`
    27  	Attachments  []ChirpAttachment `db:"attachments,json"`
    28  }
    29  
    30  // TableName returns the mapped table name.
    31  func (c Chirp) TableName() string { return "chirp" }
    32  
    33  // ChirpAttachment is an attachment, e.g. a picture to a chrip.
    34  type ChirpAttachment struct {
    35  	Type string `db:"type"`
    36  	URL  string `db:"url"`
    37  }