Storing an array in SQLite3

Viewed 398

I understand that SQLite can't directly store an array. I have just picked up the basics of Go and using GORM with SQLite and suprised to find that GORM/SQLite can create tables based on nested Structs, which is amazing, so I thinking there is surely a way to achieve storing an array even if from another table.

Example

type Post struct {
    Title   string `json:"title"`
    Body    string `json:"body"`
    Labels  <ARRAY> `json:"labels"`
}

So I would want to post the data like so

{
    "title":"Some title",
    "body":"Hello world this is a post",
    "labels":["go", "programming"]
}

Is there a simple way to achieve this in GORM?

0 Answers
Related