Formats table mutations to be in the expected proto format.
Package
@google-cloud/bigtableExample
const
mutation
=
new
Mutation
({
key
:
'gwashington'
,
method
:
'insert'
,
data
:
{
jadams
:
1
}
});
Constructors
(constructor)(mutation)
constructor
(
mutation
:
MutationConstructorObj
);
Constructs a new instance of the Mutation
class
Properties
data
data
:
Data
;
key
key
:
string
;
method
method
:
string
;
methods
static
methods
:
{
INSERT
:
string
;
DELETE
:
string
;
};
Mutation methods
INSERT => setCell DELETE => deleteFrom*
Methods
convertFromBytes(bytes, options)
static
convertFromBytes
(
bytes
:
Buffer
|
string
,
options
?:
ConvertFromBytesOptions
)
:
Buffer
|
Value
|
string
;
Parses "bytes" returned from proto service.
bytes
"\"buffer\"".__global.Buffer
| string
Base64 encoded string.
options
"\"buffer\"".__global.Buffer
| Value_2
| string
{string|number|buffer}
convertToBytes(data)
static
convertToBytes
(
data
:
Buffer
|
Data
)
:
Buffer
|
Data
;
Converts data into a buffer for proto service.
data
"\"buffer\"".__global.Buffer
| Data_2
The data to be sent.
"\"buffer\"".__global.Buffer
| Data_2
{buffer}
createTimeRange(start, end)
static
createTimeRange
(
start
:
Date
|
number
,
end
:
Date
|
number
)
:
TimeRange
;
Takes date objects and creates a time range.
start
Date
| number
The start date.
end
Date
| number
The end date.
encodeDelete(data)
static
encodeDelete
(
data
?:
Data
|
Data
[])
:
IMutation
[];
Formats a delete
mutation to what the proto service expects. Depending on what data is supplied to this method, it will return an object that can will do one of the following:
* Delete specific cells from a column. * Delete all cells contained with a specific family. * Delete all cells from an entire rows.
data
Data_2
| Data_2
[]
The entry data.
Mutation
.
encodeDelete
([
'follows:gwashington'
]);
// {
// deleteFromColumn: {
// familyName: 'follows',
// columnQualifier: 'gwashington', // as buffer
// timeRange: null // optional
// }
// }
Mutation
.
encodeDelete
([
'follows'
]);
// {
// deleteFromFamily: {
// familyName: 'follows'
// }
// }
Mutation
.
encodeDelete
();
// {
// deleteFromRow: {}
// }
// It's also possible to specify a time range when deleting specific
// columns.
Mutation
.
encodeDelete
([
{
column
:
'follows:gwashington'
,
time
:
{
start
:
new
Date
(
'March 21, 2000'
),
end
:
new
Date
(
'March 21, 2001'
)
}
}
]);
encodeSetCell(data)
static
encodeSetCell
(
data
:
Data
)
:
SetCellObj
[];
Formats an insert
mutation to what the proto service expects.
data
Data
The entity data.
Mutation
.
encodeSetCell
({
follows
:
{
gwashington
:
1
,
alincoln
:
1
}
});
// [
// {
// setCell: {
// familyName: 'follows',
// columnQualifier: 'gwashington', // as buffer
// timestampMicros: -1, // -1 means to use the server time
// value: 1 // as buffer
// }
// }, {
// setCell: {
// familyName: 'follows',
// columnQualifier: 'alincoln', // as buffer
// timestampMicros: new Date(), // uses the client's current time
// value: 1 // as buffer
// }
// }
// ]
parse(mutation)
static
parse
(
mutation
:
Mutation
)
:
IMutateRowRequest
;
Creates a new Mutation object and returns the proto JSON form.
parseColumnName(columnName)
static
parseColumnName
(
columnName
:
string
)
:
ParsedColumn
;
Parses a column name into an object.
columnName
string
Mutation
.
parseColumnName
(
'follows:gwashington'
);
// {
// family: 'follows',
// qualifier: 'gwashington'
// }
toProto()
toProto
()
:
IMutateRowRequest
;
Converts the mutation object into proto friendly JSON.