js-data

Respect Your Data

Give your data the treatment it deserves with a framework-agnostic, datastore-agnostic JavaScript ORM built for ease of use and peace of mind. Works in Node.js and in the Browser.

Get Started

DS#lastModified

DS#lastModified(resourceName[, id])

Return the timestamp of the last time either the collection for resourceName or the item of type resourceName with the given primary key was modified.

👍

You can call DS#lastModified multiple ways

  • DS#lastModified(resourceName[, id])
  • Resource#lastModified(id) - Where Resource was created by DS#defineResource

Argument

Type

Description

resourceName

string

The name of the resource to use. Unnecessary if calling lastModified directly on a Resource.

id

string or number

The primary key of the item whose last modified timestamp is to be retrieved.

Examples
// same as store.lastModified('document', 45)
Document.lastModified(45); // undefined

Document.find(45).then(function (document) {

  Document.lastModified(45); // 1234235825494
});

Using lastModified to watch an item for changes in Angular:

// watch an individual item
$scope.$watch(function () {
  return User.lastModified(1234);
}, function () {
  // do something, like:
  $scope.user = User.get(1234);
});

// watch the whole collection
$scope.$watch(function () {
  return User.lastModified();
}, function () {
  // do something, like:
  $scope.users = User.filter({
    where: {
      age: {
        '>': 30
      }
    }
  });
});
See also

📘

Need help?

Want more examples or have a question? Ask on the Slack channel or post on the mailing list then we'll get your question answered and probably update this wiki.

Updated less than a minute ago

DS#lastModified


DS#lastModified(resourceName[, id])

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.