Aceasta magazie gazduieste mai multe pachete care alcatuiesc in mod colectiv un obiect pentru documentarea maperului pentru aplicatii JavaScript folosind Amazon DynamoDB.

Notiuni de baza

Pachetul @ aws / dynamodb-data-mapper ofera o modalitate simpla de a persista si de a incarca obiectele de domeniu ale unei aplicatii in si din Amazon DynamoDB. Cand este utilizat impreuna cu decoratorii furnizati de pachetul @ aws / dynamodb-data-mapper-annotations, puteti descrie relatia dintre o clasa si reprezentarea acesteia in DynamoDB adaugand cativa decoratori:

import {atribut, hashKey, rangeKey, table,} din „@ aws / dynamodb-data-mapper-annotations”; @table (‘table_name’) class MyDomainObject {@hashKey () id: sir; @rangeKey ({defaultProvider: () => new Date ()}) createdAt: Date; @attribute () completat ?: boolean; }

Cu clasele de domenii definite, puteti interactiona cu inregistrarile din DynamoDB printr-o instanta a DataMapper:

importati {DataMapper} din „@ aws / dynamodb-data-mapper”; import DynamoDB = require (‘aws-sdk / clients / dynamodb’); const mapper = new DataMapper ({client: new DynamoDB ({region: ‘us-west-2’}), // clientul SDK folosit pentru a executa operatiuni tableNamePrefix: ‘dev_’ // optional, puteti furniza un prefix de tabel la pastrati tabelele de dezvoltatori si prod separate});

Operatiuni acceptate

Folosind obiectul mapper si clasa MyDomainObject definite mai sus, puteti efectua urmatoarele operatiuni:

a pune

Creeaza (sau suprascrie) un element din tabel

const toSave = Object.assign (newDominiuObiectul meu, {id: ‘foo’}); mapper.put (toSave) .then (objectSaved => {// inregistrarea a fost salvata});

obtine

Prelueaza un articol din DynamoDB

mapper.get (Object.assign (new MyDomainObject, {id: ‘foo’, createdAt: new Date (946684800000)})) .then (myItem => {// elementul a fost gasit}) .catch (err => { // elementul nu a fost gasit})

NB: Promisiunea returnata de cartograf va fi respinsa cu o exceptie ItemNotFoundExcept daca articolul cautat nu este gasit.

Actualizati

Actualizeaza un element din tabel

const MyItem = await mapper.get (Object.assign (new MyDomainObject, {id: ‘foo’, createdAt: new Date (946684800000)})); MyItem.completed = adevarat; asteapta mapper.update (elementul meu);

sterge

Elimina un element din tabel

await mapper.delete (Object.assign (new MyDomainObject, {id: ‘foo’, createdAt: new Date (946684800000)}));

scanare

Listeaza articolele dintr-un tabel sau index

for await (const item of mapper.scan (MyDomainObject)) {// elementele individuale vor fi cedate pe masura ce se efectueaza scanarea} // Optional, scanati un index in loc de tabel: for await (const item of mapper.

incesto subtitulado en español zofilia xxx
porno gay en castellano ver pelis eroticas
mamada gay maduras tocandose
mamadas a dos bocas abuela caliente
nicolette shea colegialas peludas
abuelas porno porno interactivo gratis
se follaron a mi mujer porno español de maduras
me follo a mi vecina se corre en el coño de su hija
maduras españolas amateur españolas follando en la playa
porno caca corridas anales
follando en el parque superculos
porno senegal videos porno para mujeres gratis
maduras impresionantes le pilla pajeandose
coños maduros super maduras
tetas amateur joven folla por dinero
porno tv inazuma eleven xxx
madura cabalgando milf camara oculta
peliculas porno de viejas monica hoyos porno
escenas porno en cine convencional viejas cachondas
porno gay guarro incesto en espanol

scan (MyDomainObject , {indexName: ‘myIndex’}))) {// articole individuale vor fi cedate pe masura ce se efectueaza scanarea}

interogare

Gaseste un anumit articol (sau o gama de articole) intr-un tabel sau index

for await (const foo of mapper.query (MyDomainObject, {id: ‘foo’})) {// elementele individuale cu o cheie hash de „foo” vor fi redate pe masura ce se efectueaza interogarea}

Operatii pe lot

Mapperul suporta, de asemenea, operatii de lot. Sub capota, lotul va fi impartit automat in bucati care se incadreaza in limitele DynamoDB (25 pentru batchPut si batchDelete, 100 pentru batchGet). Articolele pot apartine oricarui numar de tabele, iar retragerea exponentiala pentru articolele neprelucrate este gestionata automat.

batchPut

Creeaza (sau suprascrie) mai multe elemente din tabel

const toSave = [Object.assign (new MyDomainObject, {id: ‘foo’, completat: false}), Object.assign (new MyDomainObject, {id: ‘bar’, completat: false})]; for await (const persisted of mapper.batchPut (toSave)) {// articolele vor fi cedate pe masura ce sunt scrise cu succes}
batchGet

Prelueaza mai multe articole din tabel

const toGet = [Object.assign (new MyDomainObject, {id: ‘foo’, createdAt: new Date (946684800000)}), Object.assign (new MyDomainObject, {id: ‘bar’, createdAt: new Date (946684800001)} )]; for await (const gasit de mapper.batchGet (toGet)) {// articolele vor fi cedate pe masura ce sunt recuperate cu succes}

NB: Numai elementele care exista in tabel vor fi recuperate. Daca nu se gaseste o cheie, aceasta va fi omisa din rezultat.

stergeti

Elimina mai multe articole din tabel

const toRemove = [Object.assign (new MyDomainObject, {id: ‘foo’, createdAt: new Date (946684800000)}), Object.assign (new MyDomainObject, {id: ‘bar’, createdAt: new Date (946684800001)} )]; for await (const gasit de mapper.batchDelete (toRemove)) {// articolele vor fi cedate pe masura ce sunt eliminate cu succes}

Operatii cu expresii

Exemplu de aplicare
importati {AttributePath, FunctionExpression, UpdateExpression,} din „@ aws / dynamodb-expressions”; const expr = new UpdateExpression (); // a dat anotarea de mai jos @table (‘tableName’) clasa MyRecord {@hashKey () email ?: sir; @attribute () passwordHash ?: sir; @attribute () passwordSalt ?: sir; @attribute () verificat ?: boolean; @attribute () verifyToken ?: sir; } // faci o operatie de mapare dupa cum urmeaza const aRecord = Object.assign (new MyRecord (), {email, passwordHash: parola, passwordSalt: sare, verificat: fals, verifyToken: token,}); mapper.put (aRecord, {condition: new FunctionExpression (‘attribute_not_exists’, new AttributePath (’email’)}). then (/ * result handler * /);

Operatii pe durata ciclului de viata

createTable

Creeaza un tabel pentru clasa mapata si asteapta sa fie initializat:

mapper.createTable (MyDomainObject, {readCapacityUnits: 5, writeCapacityUnits: 5}) .then (() => {// tabelul a fost aprovizionat si este gata de utilizare!})
assureTableExists

Ca si createTable, dar creeaza tabelul doar daca nu exista deja:

mapper.ensureTableExists (MyDomainObject, {readCapacityUnits: 5, writeCapacityUnits: 5}) .then (() => {// tabelul a fost aprovizionat si este gata de utilizare!})
deleteTable

Sterge tabelul pentru clasa mapata si asteapta eliminarea acestuia:

asteapta mapper.deleteTable (MyDomainObject)
assureTableNotExists

Ca si deleteTable, dar sterge tabelul numai daca acesta exista:

asteapta mapper.ensureTableNotExists (MyDomainObject)

Pachete constitutive

DataMapper este dezvoltat ca un monorepo folosind lerna. Documentatia mai detaliata despre pachetele constitutive ale mapperului este disponibila vizualizand aceste pachete direct.

  • Amazon DynamoDB Automarshaller
  • Amazon DynamoDB Batch Iterator
  • Amazon DynamoDB DataMapper
  • Adnotari Amazon DynamoDB DataMapper
  • Amazon DynamoDB Data Marshaller
  • Expresii Amazon DynamoDB
  • Amazon DynamoDB Query Iterator