This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chunk = (arr, size) => arr.reduce((a, n) => a[a.length-1].length < size ? [...a.slice(0,-1), [...a[a.length-1], n]] : [...a, [n]], [[]]); | |
const a = [1,2,3,4,5,6,7,8,9] | |
console.log(chunk(a, 2)); // -> [[1, 2], [3, 4], [5, 6], [7, 8], [9]] | |
console.log(chunk(a, 3)); // -> [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | |
console.log(chunk(a, 4)); // -> [[1, 2, 3, 4], [5, 6, 7, 8], [9]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From https://docs.amplify.aws/cli/graphql-transformer/auth#field-level-authorization | |
// The code where this exception is thrown is: https://github.com/aws-amplify/amplify-js/blob/d9aa32837f15f408daba0a0104bb27042b9331da/packages/api-graphql/src/GraphQLAPI.ts#L314 | |
type User @model { | |
id: ID! | |
username: String | |
ssn: String @auth(rules: [{ allow: owner, ownerField: "username" }]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @typescript-eslint/no-var-requires */ | |
/** | |
* How to run: | |
* - export AWS_PROFILE | |
* - export AWS_REGION=us-east-1 | |
*/ | |
const DynamoDB = require("aws-sdk/clients/dynamodb"); | |
const dynamodb = new DynamoDB(); | |
const DocumentClient = new DynamoDB.DocumentClient(); |
OlderNewer