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

cloud-directory-mapper

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloud-directory-mapper

Cloud Directory Mapper for AWS Cloud Directory

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Cloud Directory Mapper for AWS Cloud Directory

Copyright (C) Clouden 2018
Author Kenneth Falck kennu@clouden.net 2018

Overview

This is an experimental JavaScript mapper for managing AWS Cloud Directory content using dynamic object facets defined with TypeScript.

Installation

To add the library to your project:

npm install --save cloud-directory-mapper

Usage

To define a dynamic object facet:

import { CloudDirectoryMapper, dynamicObjectFacet, attribute } from 'cloud-directory-mapper'
import * as AWS from 'aws-sdk'

@dynamicObjectFacet()
class Post {
  @attribute()
  postId: string

  @attribute()
  title: string

  @attribute()
  content: string
}

To create a mapper instance connected to CLOUD_DIRECTORY_ARN (environment variable):

const cloudDirectory = new AWS.CloudDirectory()
const cloudDirectoryMapper = new CloudDirectoryMapper(cloudDirectory, process.env.CLOUD_DIRECTORY_ARN)

To create a new child object under a known parent object (/posts) using the link name postId:

const post = new Post()
post.postId = '123'
post.title = 'hello world'
post.content = 'longer content'
await mapper.createObject(post, '/posts', postId)

To retrieve child objects of a known parent object:

const posts = [] as Post[]
for await (const post of mapper.getChildObjects(Post, '/posts')) {
  posts.push(post)
}

To retrieve a single child object of a known parent object using the link name postId:

const postId = '123'
const post = await mapper.getObject(Post, '/posts', postId)

To update the retrieved child object:

post.title = 'foo bar'
await mapper.updateObject(post)

Note that Cloud Directory Mapper automatically keeps track of the objectId of the Post object retrieved using getObject(). This allows the updateObject() to work without specifying any path or object identifier.

FAQs

Package last updated on 28 Nov 2018

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