Documentation ¶
Index ¶
- func BsonToRedditContent(bsonBytes bson.Raw) (*pb.RedditContent, error)
- func GetEnv(str string) string
- func GetEnvDefault(str string, def string) string
- func GetEnvInt(str string) int
- func IsValidForDatabase(rc *pb.RedditContent) error
- func IsValidFullID(ID string) bool
- func IsValidID(ID string) bool
- type BsonStruct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BsonToRedditContent ¶
func BsonToRedditContent(bsonBytes bson.Raw) (*pb.RedditContent, error)
takes in a bson.Raw object and returns a filled pb.RedditContent mainly used to convert mongo database compatible data to grpc compatible data
func GetEnvDefault ¶
equivelant to getEnv except doesn't cause an error and substitutes a default value (def)
func IsValidForDatabase ¶
func IsValidForDatabase(rc *pb.RedditContent) error
perform this check on RedditContents before attempting to insert them into the database
returns nil if valid
func IsValidFullID ¶
the listings in the database must store IDs in the form of t-_------, or regex ^t[1-6]_[a-z0-9]{6}$
Types ¶
type BsonStruct ¶
type BsonStruct struct { ID string `bson:"_id"` Listing bsonStructMetadata Entries []bsonStructEntry }
middle-man object which bson pulled from database can be directly converted to (and vice versa), before converting to pb.RedditContent
func RedditContentToBson ¶
func RedditContentToBson(r pb.RedditContent) BsonStruct
converts standard pb.RedditContent to object that can be parsed to database-compliant bson struct