šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
DemoInstallSign in
Socket

@aws-amplify/datastore

Package Overview
Dependencies
Maintainers
9
Versions
1915
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/datastore

AppSyncLocal support for aws-amplify

5.0.82
latest
Source
npm
Version published
Weekly downloads
801K
4.15%
Maintainers
9
Weekly downloads
Ā 
Created

What is @aws-amplify/datastore?

@aws-amplify/datastore is a library that provides a programming model for leveraging shared and distributed data without writing additional code for offline and online scenarios. It is part of the AWS Amplify framework and is designed to work seamlessly with AWS AppSync for real-time and offline-first data access.

What are @aws-amplify/datastore's main functionalities?

Model Definition

Defines the data model schema for the application. This is the first step in setting up DataStore, where you define the structure of your data.

const { initSchema } = require('@aws-amplify/datastore');
const { schema } = require('./schema');

const { Post } = initSchema(schema);

CRUD Operations

Provides basic CRUD (Create, Read, Update, Delete) operations for interacting with the data models. This allows developers to easily manage their data.

const { DataStore } = require('@aws-amplify/datastore');

// Create
await DataStore.save(new Post({ title: 'New Post', content: 'This is a new post' }));

// Read
const posts = await DataStore.query(Post);

// Update
const original = await DataStore.query(Post, '123');
await DataStore.save(Post.copyOf(original, updated => {
  updated.title = 'Updated Title';
}));

// Delete
await DataStore.delete(Post, '123');

Real-time and Offline Sync

Enables real-time data synchronization and offline capabilities. DataStore automatically syncs data between the local store and the cloud, ensuring data consistency.

const { DataStore } = require('@aws-amplify/datastore');

DataStore.observe(Post).subscribe(msg => {
  console.log(msg.model, msg.opType, msg.element);
});

Conflict Resolution

Handles conflict resolution when data changes occur both locally and in the cloud. Developers can define custom conflict resolution strategies.

const { DataStore, syncExpression } = require('@aws-amplify/datastore');

DataStore.configure({
  syncExpressions: [
    syncExpression(Post, () => {
      return post => post.status('eq', 'published');
    })
  ]
});

Other packages similar to @aws-amplify/datastore

FAQs

Package last updated on 28 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts