Record

Record

Create a Resource Record object.

Constructor

new Record(type, metadata)

Parameters:
Name Type Description
type string

The record type, e.g. A, AAAA, MX.

metadata object

The metadata of this record.

Properties
Name Type Description
name string

The name of the record, e.g. www.example.com..

data Array.<string>

Defined in RFC 1035, section 5 and RFC 1034, section 3.6.1.

ttl number

Seconds that the resource is cached by resolvers.

Example
const {DNS} = require('@google-cloud/dns');
const dns = new DNS();
const zone = dns.zone('my-awesome-zone');

const record = zone.record('a', {
  name: 'example.com.',
  ttl: 86400,
  data: '1.2.3.4'
});

Members

data

metadata

Properties:
Name Type Description
name string
data Array.<string>
metadata.ttl number

type

Methods

delete(callbackopt) → {Promise.<DeleteRecordResponse>}

Delete this record by creating a change on your zone. This is a convenience method for:

zone.createChange({
  delete: record
}, (err, change, apiResponse) => {});
Parameters:
Name Type Attributes Description
callback DeleteRecordCallback <optional>

Callback function.

Returns:
Type Description
Promise.<DeleteRecordResponse>
See:
Example
const {DNS} = require('@google-cloud/dns');
const dns = new DNS();
const zone = dns.zone('zone-id');
const record = zone.record('a', {
  name: 'example.com.',
  ttl: 86400,
  data: '1.2.3.4'
});

record.delete((err, change, apiResponse) => {
  if (!err) {
    // Delete change modification was created.
  }
});

//-
// If the callback is omitted, we'll return a Promise.
//-
record.delete().then((data) => {
  const change = data[0];
  const apiResponse = data[1];
});

toJSON() → {object}

Serialize the record instance to the format the API expects.

Returns:
Type Description
object

toString() → {string}

Convert the record to a string, formatted for a zone file.

Returns:
Type Description
string