# engine-composition-crud

> The default module for creating, reading, updating and deleting Engine instances.

Latest version **1.0.1** (published 2016-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install engine-composition-crud
pnpm add engine-composition-crud
yarn add engine-composition-crud
bun add engine-composition-crud
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-02-15 |
| First published | 2015-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | jillix |
| Maintainers | ionicabizau |
| Keywords | engine, jillix, composition, crud |

## Links

- npm: https://www.npmjs.com/package/engine-composition-crud
- Repository: https://github.com/jillix/engine-composition-crud
- Homepage: https://github.com/jillix/engine-composition-crud#readme
- Issues: https://github.com/jillix/engine-composition-crud/issues
- npm.io page: https://npm.io/package/engine-composition-crud

## Dependencies (7)

- [r-json](https://npm.io/package/r-json.md) ^1.1.0
- [w-json](https://npm.io/package/w-json.md) ^1.2.0
- [is-there](https://npm.io/package/is-there.md) ^4.3.0
- [same-time](https://npm.io/package/same-time.md) ^2.3.0
- [engine-paths](https://npm.io/package/engine-paths.md) github:jillix/engine-paths
- [engine-comp-crud-errors](https://npm.io/package/engine-comp-crud-errors.md) github:jillix/engine-comp-errors
- [engine-composition-adapter](https://npm.io/package/engine-composition-adapter.md) github:jillix/engine-composition-adapter

## Recent versions

- 1.0.1 (latest) — 2016-02-15
- 1.0.0 — 2015-12-02

## README

# engine-composition-crud [![Version](https://img.shields.io/npm/v/engine-composition-crud.svg)](https://www.npmjs.com/package/engine-composition-crud) [![Downloads](https://img.shields.io/npm/dt/engine-composition-crud.svg)](https://www.npmjs.com/package/engine-composition-crud)

> The default module for creating, reading, updating and deleting Engine instances.

## Installation

```sh
$ npm i --save engine-composition-crud
```

## Example

```js
const CompositionCRUD = require("engine-composition-crud")
    , EnginePaths = require("engine-paths")
    ;

// Initialize CRUD
var crud = new CompositionCRUD(
    new EnginePaths("path/to/some/app")
);

// Create the layout instance
crud.create("layout", /* optional data, */ function (err, data) {
    console.log(err || data);
    // => { name: "layout" }
});

// Read the layout instance
crud.read("layout", function (err, data) {
    console.log(err || data);
    // => { name: "...", ...}
});

// Update the layout instance
crud.update("layout", { module: "some-module" }, function (err, data) {
    console.log(err || data);
    // => { name: "...", module: "some-module", ...}
});
```

## Documentation

### `constructor(paths)`
CompositionCRUD
Creates a new instance of `CompositionCRUD`.

#### Params
- **EnginePaths** `paths`: The `EnginePaths` instance.

### `exists(name, cb)`
Checks if an instance exists.

#### Params
- **String** `name`: The instance name.
- **Function** `cb`: The callback function.

### `list(cb)`
List the instances.

#### Params
- **Function** `cb`: The callback function.

### `readAll(cb)`
Read all the instances.

#### Params
- **Function** `cb`: The callback function.

### `create(name, data, cb)`
Creates a new instance.

#### Params
- **String** `name`: The instance name.
- **Object** `data`: The instance content.
- **Function** `cb`: The callback function.

### `read(name, cb)`
Reads the instance content.

#### Params
- **String** `name`: The instance name.
- **Function** `cb`: The callback function.

### `update(name, data, cb)`
Updates the instance content.

#### Params
- **String** `name`: The instance name.
- **Object** `data`: The instance content.
- **Function** `cb`: The callback function.

### `remove(name, cb)`
Removes the instance.

#### Params
- **String** `name`: The instance name.
- **Function** `cb`: The callback function.

### `rename(oldName, newName, cb)`
Renames the instance.

#### Params
- **String** `oldName`: The old instance name.
- **String** `newName`: The new instance name.
- **Function** `cb`: The callback function.

### `upsert(name, data, cb)`
Creates or updates the specified instance.

#### Params
- **String** `name`: The instance name.
- **Object** `data`: The instance content.
- **Function** `cb`: The callback function.

### `readFile(filePath, content, cb)`
Reads the file from the app.

#### Params
- **String** `filePath`: The file path.
- **String** `content`: The file content.
- **Function** `cb`: The callback function.

### `writeFile(filePath, content, cb)`
Writes the file in the app.

#### Params
- **String** `filePath`: The file path.
- **String** `content`: The file content.
- **Function** `cb`: The callback function.

## How to contribute
Have an idea? Found a bug? See [how to contribute][contributing].

## Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:

 - [`engine-app`](https://github.com/jillix/engine-app#readme) by jillix

## License

[MIT][license] © [jillix][website]

[license]: http://showalicense.com/?fullname=jillix%20%3Ccontact%40jillix.com%3E%20(http%3A%2F%2Fjillix.com)&year=2015#license-mit
[website]: http://jillix.com
[contributing]: /CONTRIBUTING.md
[docs]: /DOCUMENTATION.md

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