@nestjs-dash/in-memory 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @nestjs-dash/in-memory
|
|
2
|
+
|
|
3
|
+
A zero-setup, dependency-free `ResourceAdapter` implementation for nestjs-dash — no database, no Docker, no connection config. It's also the **reference adapter**: `@nestjs-dash/adapter`'s conformance test suite checks every real ORM adapter's behavior against this one.
|
|
4
|
+
|
|
5
|
+
Best uses: the fastest way to try nestjs-dash, quick prototypes, and tests.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @nestjs-dash/in-memory
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createInMemoryResourceFromModel } from '@nestjs-dash/in-memory';
|
|
17
|
+
import { Resource, TextColumn } from '@nestjs-dash/core';
|
|
18
|
+
import { AdminModule } from '@nestjs-dash/nestjs';
|
|
19
|
+
|
|
20
|
+
class AuthorResource extends Resource {
|
|
21
|
+
static override slug = 'authors';
|
|
22
|
+
static override table(table) {
|
|
23
|
+
return table.columns([TextColumn.make('id'), TextColumn.make('name').sortable().searchable()]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
AuthorResource.adapter = createInMemoryResourceFromModel(AuthorResource, {
|
|
28
|
+
records: [{ id: '1', name: 'Ada Lovelace' }],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
AdminModule.forRoot({
|
|
32
|
+
panel: { resources: [AuthorResource] },
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
No async factory needed — since there's no external connection to inject, `AdminModule.forRoot` (not `forRootAsync`) works fine here.
|
|
37
|
+
|
|
38
|
+
Data only lives in memory for the process lifetime — restarting the app resets everything.
|
|
39
|
+
|
|
40
|
+
## Part of nestjs-dash
|
|
41
|
+
|
|
42
|
+
This package is one piece of [nestjs-dash](https://github.com/nestjs-dash/nestjs-dash), a NestJS-native admin framework. See the `example-in-memory` demo app for a complete `Author`/`Book` admin with relations, seeded directly in `app.module.ts`.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs-dash/in-memory",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Zero-setup in-memory adapter for NestJS Dash — the reference ResourceAdapter implementation the conformance suite checks every other adapter against",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@nestjs-dash/adapter": "1.0.0",
|
|
21
|
-
"@nestjs-dash/core": "1.
|
|
21
|
+
"@nestjs-dash/core": "1.1.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@nestjs-dash/typescript-config": "0.1.0",
|