Data Mapping Library
The Data Mapping Library is a Go-based package for managing structured data mappings, operations, and requests. It provides a flexible and extendable framework to create bulk requests, perform data mappings, and handle operations in a scalable way, especially useful for complex systems integration tasks.
Table of Contents
Installation
To use the Data Mapping Library, ensure that your Go project meets the module dependencies. Install it via:
Import the packages needed in your Go files to use the various features of this library.
Usage
Data Mapping
The dataMap
package provides a DataMap
type, which is a map for storing key-value pairs and offers methods to access and validate entries.
Example
Operations
The operation
package defines methods to create different operation types like POST, PATCH, and DELETE. These operations store data and are intended for CRUD-style operations.
Example
Bulk Requests
Use the requests
package to create bulk requests containing multiple operations. This package allows you to group operations together and perform batch processing.
Example
Package Details
dataMap
Defines a map for key-value storage with methods:
Has(key string) bool
: Checks if a key exists.Get(key string) (string, error)
: Retrieves the value for a given key.
mapping
Handles data processing and mappings:
Mapping(transitionType string, inputFields []string, outputFields []string, transitions map[string]string, rawData []dataMap.DataMap) (requests.Request, error)
ProcessRecord(inputFields []string, transitions map[string]string, rawData dataMap.DataMap) (data.Data, error)
data
Defines a flexible Data
map type with methods:
Set(key string, value interface{})
: Sets a key-value pair.Delete(key string)
: Deletes a key.ToJson() ([]byte, error)
: Converts data to JSON.
operation
Handles CRUD operation creation:
CreateOperation(method string, path string, data data.Data) Operation
ToJson() ([]byte, error)
: Converts an operation to JSON.
operations
Manages bulk operation groups:
CreateOperations([]operation.Operation) Operations
: Creates a bulk operation group.ToJson() ([]byte, error)
: Converts operations to JSON.
requests
Manages bulk requests:
CreateBulkRequest(data operations.Operations) Request
: Creates a bulk request object.ToJson() ([]byte, error)
: Converts a request to JSON.