# faunadb-wrap

> Another Node.js wrapper to interact with FaunaDB

Latest version **1.0.0** (published 2021-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install faunadb-wrap
pnpm add faunadb-wrap
yarn add faunadb-wrap
bun add faunadb-wrap
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-04-18 |
| First published | 2021-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 19.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Martín M. |
| Maintainers | skydiver |

## Links

- npm: https://www.npmjs.com/package/faunadb-wrap
- npm.io page: https://npm.io/package/faunadb-wrap

## Dependencies (1)

- [faunadb](https://npm.io/package/faunadb.md) ^4.2.0

## Recent versions

- 1.0.0 (latest) — 2021-04-18

## README

# faunadb-wrap
> Another Node.js wrapper to interact with FaunaDB


## Install
`npm install faunadb-wrap`

## Usage

### Create collections
```js
await fauna.createCollection('my_collection');
```

## Delete collections
```js
await fauna.deleteCollection('my_collection');
```

### Create indexes
```js
// create an index called "index_name"
await fauna.createIndex('my_collection', 'index_name');

// create index with terms
await fauna.createIndex('customers', 'index_with_terms', {
  terms: [{ field: ['data', 'firstName'] }]
});

// create index with field firstName unique
await fauna.createIndex('customers', 'index_unique', {
  terms: [{ field: ['data', 'firstName'] }],
  unique: true
});
```

### Delete indexes
```js
await fauna.deleteIndex('index_name');
```

### Create documents
```js
await fauna.createDocument('customers', {
  firstName: 'John',
  lastName: 'Smith',
  age: 40
});
```

### Retrieve documents
```js
const documents = await fauna.retrieveDocuments('customers');
console.log(documents);             // PRINT ALL DOCUMENTS
console.log(documents[0]);          // PRINT FIRST DOCUMENT
console.log(documents[0].data);     // PRINT DOCUMENT FIELDS
```

### Update document
```js
// Update firstName, age and add tags
await fauna.updateDocument('customers', '291699840069403141', {
  firstName: 'Peter',
  age: 41,
  tags: ['customer', 'financial']
});

// Remove tags property
await fauna.updateDocument('customers', '291699840069403141', {
  tags: null
});
```

### Delete document
```js
await fauna.deleteDocument('customers', '291699840069403141');
```

---
_Source: https://npm.io/package/faunadb-wrap · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
