예제 #1
0
// PersistCronResult saves itself to DynamoDB
func PersistCronResult(key string, memo string, s, e time.Time) error {
	items := map[string]*dynamodb.AttributeValue{}
	items["Key"] = aws.DynamoAttributeS(key)
	items["Memo"] = aws.DynamoAttributeS(memo)
	items["LastStartDate"] = aws.DynamoAttributeS(misc.TimeToString(s))
	items["LastEndDate"] = aws.DynamoAttributeS(misc.TimeToString(e))
	_, err := aws.DynamoPutItem(cronTable, items)
	return err
}
예제 #2
0
// GetSession retrives a specified session from DynamoDB
//  @param  id string
//  @return session models.Session
func GetSession(id string) (session Session, err error) {
	record, err := aws.DynamoRecord(sessionTable, map[string]*dynamodb.AttributeValue{
		"ID": aws.DynamoAttributeS(id),
	})
	if err != nil {
		return session, nil
	}
	return toSession(record), nil
}
예제 #3
0
// GetCronResult retrives a specified cron result from DynamoDB
//  @return session models.Session
func GetCronResult(key string) (result CronResult, err error) {
	record, err := aws.DynamoRecord(cronTable, map[string]*dynamodb.AttributeValue{
		"Key": aws.DynamoAttributeS(key),
	})
	if err != nil {
		return result, nil
	}
	return toCronResult(record), nil
}
예제 #4
0
func (s Session) persist() error {
	items := map[string]*dynamodb.AttributeValue{}
	items["ID"] = aws.DynamoAttributeS(s.ID)
	if s.Abbreviation != "" {
		items["Abbreviation"] = aws.DynamoAttributeS(s.Abbreviation)
	}
	if s.Title != "" {
		items["Title"] = aws.DynamoAttributeS(s.Title)
	}
	if s.Abstract != "" {
		items["Abstract"] = aws.DynamoAttributeS(s.Abstract)
	}
	// items["Recommended"] = aws.DynamoAttributeB(s.Recommended)
	// session.Speakers = []string{}
	items["Date"] = aws.DynamoAttributeN64(s.Date)
	items["Start"] = aws.DynamoAttributeD(s.Start)
	items["End"] = aws.DynamoAttributeD(s.End)
	if s.Room != "" {
		items["Room"] = aws.DynamoAttributeS(s.Room)
	}
	if s.Length != "" {
		items["Length"] = aws.DynamoAttributeS(s.Length)
	}
	items["TypeId"] = aws.DynamoAttributeN(s.TypeID)
	if s.Type != "" {
		items["Type"] = aws.DynamoAttributeS(s.Type)
	}
	items["TrackId"] = aws.DynamoAttributeN(s.TrackID)
	if s.Track != "" {
		items["Track"] = aws.DynamoAttributeS(s.Track)
	}
	items["LevelId"] = aws.DynamoAttributeN(s.LevelID)
	if s.Level != "" {
		items["Level"] = aws.DynamoAttributeS(s.Level)
	}
	_, err := aws.DynamoPutItem(sessionTable, items)
	return err
}