Add LastUpdateType to CIF Metadata
This commit is contained in:
@@ -18,10 +18,11 @@ const Doctype = "CifMetadata"
|
||||
// The type describing the CifMetadata 'type' in the database.
|
||||
// This type will be moved to owlboard/go-types
|
||||
type CifMetadata struct {
|
||||
Doctype string `bson:"type"`
|
||||
LastUpdate time.Time `bson:"lastUpdate"`
|
||||
LastTimestamp int64 `bson:"lastTimestamp"`
|
||||
LastSequence int64 `bson:"lastSequence"`
|
||||
Doctype string `bson:"type"`
|
||||
LastUpdate time.Time `bson:"lastUpdate"`
|
||||
LastTimestamp int64 `bson:"lastTimestamp"`
|
||||
LastSequence int64 `bson:"lastSequence"`
|
||||
LastUpdateType string `bson:"lastUpdateType"`
|
||||
}
|
||||
|
||||
// Fetches the CifMetadata from the database, returns nil if no metadata exists - before first initialisation for example.
|
||||
@@ -45,17 +46,18 @@ func GetCifMetadata() (*CifMetadata, error) {
|
||||
}
|
||||
|
||||
// Uses upsert to Insert/Update the CifMetadata in the database
|
||||
func PutCifMetadata(metadata *CifMetadata) bool {
|
||||
func PutCifMetadata(metadata *CifMetadata, lastUpdateType string) bool {
|
||||
database := MongoClient.Database(databaseName)
|
||||
collection := database.Collection(metaCollection)
|
||||
options := options.Update().SetUpsert(true)
|
||||
filter := bson.M{"type": Doctype}
|
||||
update := bson.M{
|
||||
"$set": bson.M{
|
||||
"type": Doctype,
|
||||
"lastUpdate": metadata.LastUpdate,
|
||||
"lastTimestamp": metadata.LastTimestamp,
|
||||
"lastSequence": metadata.LastSequence,
|
||||
"type": Doctype,
|
||||
"lastUpdate": metadata.LastUpdate,
|
||||
"lastTimestamp": metadata.LastTimestamp,
|
||||
"lastSequence": metadata.LastSequence,
|
||||
"lastUpdateType": lastUpdateType,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user