Beispiel #1
5
func GetPostsByID(db *gorm.DB, categoryid string) interface{} {
	db.Preload("Category", "ID = ?", categoryid).Order("post_created desc").Find(&ReturnData.Posts, "category_id =?", categoryid)
	return ReturnData.Posts
}
Beispiel #2
0
func GetPostsByPage(db *gorm.DB, pageid string) interface{} {
	db.Preload("Category").Order("post_created desc").Find(&ReturnData.Posts, "page_id =?", pageid)
	return ReturnData.Posts
}
Beispiel #3
0
func GetPosts(db *gorm.DB) interface{} {
	db.Preload("Category").Order("post_created desc").Find(&ReturnData.Posts)
	return ReturnData.Posts
}
Beispiel #4
0
func GetPost(db *gorm.DB, postid string) interface{} {
	post := Post{}
	db.Preload("Category").First(&post, "id =?", postid)
	return post
}
Beispiel #5
0
func GetCategories(db *gorm.DB) interface{} {
	db.Find(&ReturnData.Categories)
	return ReturnData.Categories
}