Skip to content

Commit 53dfe49

Browse files
mvhentenCopilot
andauthored
docs: Revise documentation section in README.md (#18)
* docs: Revise documentation section in README.md The pulling the example implementation up in the README because that's what people need. * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d3f86e2 commit 53dfe49

File tree

1 file changed

+6
-62
lines changed

1 file changed

+6
-62
lines changed

README.md

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,6 @@ Install this generator in your typespec project:
1010

1111
Then, annotate your models using `@entity`, `@index`, `@createdAt`, `@updatedAt`, `@label`
1212

13-
## Documentation
14-
15-
See [./tsp/main.tsp](/tsp/main.tsp) for the type definitions of the annotations.
16-
17-
```typespec
18-
19-
/**
20-
* Generates a DynamoDB entity definition for this model.
21-
*/
22-
extern dec entity(
23-
target: Model,
24-
entity: string,
25-
service: string,
26-
version?: int32
27-
);
28-
29-
/**
30-
* Adds the ElectroDB "label" property to the attribute definition.
31-
* See https://electrodb.dev/en/modeling/attributes/#label
32-
*/
33-
extern dec label(target: ModelProperty, label: string);
34-
35-
/**
36-
* Define a "createdAt" timestamp. See https://electrodb.dev/en/recipes/created-at-updated-at/
37-
*/
38-
extern dec createdAt(target: ModelProperty, label?: string);
39-
40-
/**
41-
* Define a "updatedAt" timestamp. See https://electrodb.dev/en/recipes/created-at-updated-at/
42-
*/
43-
extern dec updatedAt(target: ModelProperty, label?: string);
44-
45-
/**
46-
* Define an ElectroDB index. See https://electrodb.dev/en/modeling/indexes/
47-
*
48-
* Use either shorthand definition:
49-
*
50-
* `@index("persons", { pk: [Persons.pk] })`
51-
*
52-
* Or full access pattern:
53-
*
54-
55-
model AccessPattern {
56-
index?: string;
57-
collection?: string | string[];
58-
type?: IndexType = IndexType.isolated;
59-
pk?: ModelProperty[] | {
60-
field?: string = "pk";
61-
composite: ModelProperty[];
62-
};
63-
sk?: ModelProperty[] | {
64-
field?: string = "sk";
65-
composite: ModelProperty[] = #[];
66-
};
67-
}
68-
*
69-
*/
70-
extern dec index(target: Model, name: string, accessPattern: AccessPattern);
71-
72-
```
73-
7413
## Example
7514

7615
Take a peek at the [./demo/main.tsp](./demo/main.tsp) for an of how this works:
@@ -279,5 +218,10 @@ export declare const Person: {
279218
readonly version: "1";
280219
};
281220
};
282-
283221
```
222+
223+
## Documentation
224+
225+
This extension itself is driven by TypeSpec type definitions, mostly pieced together by reading existing (REST) extensions and https://typespec.io/docs/extending-typespec/create-decorators/
226+
227+
See [./tsp/main.tsp](/tsp/main.tsp) for the type definitions of the annotations.

0 commit comments

Comments
 (0)