示例#1
-1
func (q *Query) query(in *SDK.QueryInput) (*QueryResult, error) {
	if !q.HasCondition() {
		errData := &DynamoError{}
		errData.AddMessage("condition is missing, you must specify at least one condition")
		return nil, errData
	}
	in.KeyConditionExpression = q.formatConditions()
	in.ExpressionAttributeValues = q.formatConditionValues()
	in.ExpressionAttributeNames = q.formatConditionNames()

	if q.HasIndex() {
		in.IndexName = String(q.index)
	}
	if q.HasLimit() {
		in.Limit = Long(q.limit)
	}

	req, err := q.table.db.client.Query(in)
	if err != nil {
		log.Error("[DynamoDB] Error in `Query` operation, table="+q.table.name, err)
		return nil, err
	}

	res := &QueryResult{
		Items:            req.Items,
		LastEvaluatedKey: req.LastEvaluatedKey,
		Count:            *req.Count,
		ScannedCount:     *req.ScannedCount,
	}
	return res, nil
}
示例#2
-1
文件: edge.go 项目: sir-wiggles/bcfs
func (d *Driver) query(key *dynamodb.QueryInput) []map[string]*dynamodb.AttributeValue {
	items := make([]map[string]*dynamodb.AttributeValue, 100)
	for {
		resp, err := d.Connection.Query(key)
		if err != nil {
			log.Println(err.Error())
			continue
		}
		items = append(items, resp.Items...)
		if resp.LastEvaluatedKey == nil {
			break
		}
		key.ExclusiveStartKey = resp.LastEvaluatedKey
	}
	return resp.Items
}