Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Entry

Hierarchy

  • { fields: T; metadata?: MetadataProps; sys: EntityMetaSysProps }
  • DefaultElements<EntryProps>
  • { archive: any; delete: any; getSnapshot: any; getSnapshots: any; isArchived: any; isDraft: any; isPublished: any; isUpdated: any; publish: any; unarchive: any; unpublish: any; update: any }
    • Entry

Index

Properties

fields

fields: T

Optional metadata

metadata: MetadataProps

sys

Methods

archive

  • archive(): Promise<Entry>
  • Archives the object

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getEntry('<entry_id>'))
    .then((entry) => entry.archive())
    .then((entry) => console.log(`Entry ${entry.sys.id} archived.`))
    .catch(console.error)

    Returns Promise<Entry>

    Object returned from the server with updated metadata.

delete

  • delete(): Promise<void>
  • Deletes this object on the server.

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getEntry('<entry_id>'))
    .then((entry) => entry.delete())
    .then(() => console.log(`Entry deleted.`))
    .catch(console.error)

    Returns Promise<void>

    Promise for the deletion. It contains no data, but the Promise error case should be handled.

getSnapshot

  • Gets a snapshot of an entry

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getEntry('<entry_id>'))
    .then((entry) => entry.getSnapshot('<snapshot_id>'))
    .then((snapshot) => console.log(snapshot))
    .catch(console.error)

    Parameters

    • snapshotId: string

      Id of the snapshot

    Returns Promise<Snapshot<EntryProps>>

getSnapshots

  • Gets all snapshots of an entry

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getEntry('<entry_id>'))
    .then((entry) => entry.getSnapshots())
    .then((snapshots) => console.log(snapshots.items))
    .catch(console.error)

    Returns Promise<Collection<Snapshot<EntryProps>, SnapshotProps<EntryProps>>>

isArchived

  • isArchived(): boolean
  • Checks if entry is archived. This means it's not exposed to the Delivery/Preview APIs.

    Returns boolean

isDraft

  • isDraft(): boolean
  • Checks if the entry is in draft mode. This means it is not published.

    Returns boolean

isPublished

  • isPublished(): boolean
  • Checks if the entry is published. A published entry might have unpublished changes

    Returns boolean

isUpdated

  • isUpdated(): boolean
  • Checks if the entry is updated. This means the entry was previously published but has unpublished changes.

    Returns boolean

publish

  • publish(): Promise<Entry>
  • Publishes the object

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getEntry('<entry_id>'))
    .then((entry) => entry.publish())
    .then((entry) => console.log(`Entry ${entry.sys.id} published.`))
    .catch(console.error)

    Returns Promise<Entry>

    Object returned from the server with updated metadata.

toPlainObject

unarchive

  • unarchive(): Promise<Entry>
  • Unarchives the object

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getEntry('<entry_id>'))
    .then((entry) => entry.unarchive())
    .then((entry) => console.log(`Entry ${entry.sys.id} unarchived.`))
    .catch(console.error)

    Returns Promise<Entry>

    Object returned from the server with updated metadata.

unpublish

  • unpublish(): Promise<Entry>
  • Unpublishes the object

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getEntry('<entry_id>'))
    .then((entry) => entry.unpublish())
    .then((entry) => console.log(`Entry ${entry.sys.id} unpublished.`))
    .catch(console.error)

    Returns Promise<Entry>

    Object returned from the server with updated metadata.

update

  • update(): Promise<Entry>
  • Sends an update to the server with any changes made to the object's properties

    example
    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getEntry('<entry_id>'))
    .then((entry) => {
      entry.fields.title['en-US'] = 'New entry title'
      return entry.update()
    })
    .then((entry) => console.log(`Entry ${entry.sys.id} updated.`))
    .catch(console.error)

    Returns Promise<Entry>

    Object returned from the server with updated changes.