mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
Added page_id field to Articles
This commit is contained in:
@@ -10,6 +10,7 @@ type Article struct {
|
|||||||
IdName string `json:"id_name" bson:"id_name"`
|
IdName string `json:"id_name" bson:"id_name"`
|
||||||
Date int64 `json:"date" bson:"date"`
|
Date int64 `json:"date" bson:"date"`
|
||||||
Content gin.H `json:"content" bson:"content"`
|
Content gin.H `json:"content" bson:"content"`
|
||||||
|
PageID string `json:"page_id" bson:"page_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var articlesLocation = database.Location{Database: "gohcms", Collection: "articles"}
|
var articlesLocation = database.Location{Database: "gohcms", Collection: "articles"}
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ var Article1, _ = bson.Marshal(Article{
|
|||||||
IdName: "test_article_1",
|
IdName: "test_article_1",
|
||||||
Date: 1671482492,
|
Date: 1671482492,
|
||||||
Content: gin.H{},
|
Content: gin.H{},
|
||||||
|
PageID: "blog",
|
||||||
})
|
})
|
||||||
|
|
||||||
var Article2, _ = bson.Marshal(Article{
|
var Article2, _ = bson.Marshal(Article{
|
||||||
IdName: "test_article_2",
|
IdName: "test_article_2",
|
||||||
Date: 1671899112,
|
Date: 1671899112,
|
||||||
Content: gin.H{},
|
Content: gin.H{},
|
||||||
|
PageID: "blog",
|
||||||
})
|
})
|
||||||
|
|
||||||
var BSONConvertedArticles = [][]byte{Article1, Article2}
|
var BSONConvertedArticles = [][]byte{Article1, Article2}
|
||||||
|
|||||||
+4
-1
@@ -4,7 +4,7 @@ const db = conn.getDB("gohcms")
|
|||||||
db.createCollection('articles', {
|
db.createCollection('articles', {
|
||||||
validator: {
|
validator: {
|
||||||
$jsonSchema: {
|
$jsonSchema: {
|
||||||
required: ['content', 'date', 'id_name'],
|
required: ['content', 'date', 'id_name', 'page_id'],
|
||||||
properties: {
|
properties: {
|
||||||
_id: {
|
_id: {
|
||||||
bsonType: 'objectId'
|
bsonType: 'objectId'
|
||||||
@@ -18,6 +18,9 @@ db.createCollection('articles', {
|
|||||||
id_name: {
|
id_name: {
|
||||||
bsonType: 'string',
|
bsonType: 'string',
|
||||||
pattern: '^.+$'
|
pattern: '^.+$'
|
||||||
|
},
|
||||||
|
page_id: {
|
||||||
|
bsonType: 'string'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user