Esempio n. 1
0
func fixtureUser(db *dynamodb.DynamoDB) error {
	params := &dynamodb.PutItemInput{
		Item: map[string]*dynamodb.AttributeValue{
			"id": {
				S: aws.String("uid123"),
			},
			"oauthid": {
				S: aws.String("google:1234"),
			},
			"email": {
				S: aws.String("*****@*****.**"),
			},
			"username": {
				S: aws.String("username"),
			},
			"created_at": {
				N: aws.String("123456789"),
			},
			"lastlogin": {
				N: aws.String("123456789"),
			},
		},
		TableName: aws.String("user"),
	}
	_, err := db.PutItem(params)

	if err != nil {
		return err
	}

	return nil
}
Esempio n. 2
0
func fixturePost(db *dynamodb.DynamoDB) error {
	params := &dynamodb.PutItemInput{
		Item: map[string]*dynamodb.AttributeValue{
			"id": {
				S: aws.String("pid123"),
			},
			"uid": {
				S: aws.String("uid123"),
			},
			"wall_id": {
				S: aws.String("1"),
			},
			"message": {
				S: aws.String("message"),
			},
			"created_at": {
				N: aws.String(strconv.FormatInt(time.Now().UnixNano(), 10)),
			},
		},
		TableName: aws.String("post"),
	}
	_, err := db.PutItem(params)
	if err != nil {
		return err
	}

	return nil
}
Esempio n. 3
0
func putResource(svc *dynamodb.DynamoDB, resource Resource, tableName string) error {
	item, err := dynamodbattribute.ConvertToMap(resource)
	if err != nil {
		return err
	}
	_, err = svc.PutItem(&dynamodb.PutItemInput{
		Item:      item,
		TableName: aws.String(tableName),
	})
	return err

}
Esempio n. 4
0
func handleAdd(subject string) {
	fmt.Println("Add admin", subject)

	var client *dynamodb.DynamoDB = dbutil.CreateDynamoDBClient()
	params := &dynamodb.PutItemInput{
		TableName: aws.String(ddl.AdminTableName),
		Item: map[string]*dynamodb.AttributeValue{
			"AdminID": {S: aws.String(subject)},
		},
		Expected: map[string]*dynamodb.ExpectedAttributeValue{
			"AdminID": {Exists: aws.Bool(false)},
		},
	}
	_, err := client.PutItem(params)

	if err != nil {
		fmt.Println(err.Error())
		return
	}
}
Esempio n. 5
0
func insertItem(db *dynamodb.DynamoDB) error {
	var _, err = db.PutItem(putItemInput())
	return err
}