Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More ā†’
Socket
Sign inDemoInstall
Socket

@aws-amplify/datastore

Package Overview
Dependencies
Maintainers
0
Versions
1817
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.66-unstable.29b6c3f.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
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 19 Dec 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc