Skip to content

Commit 663f215

Browse files
authored
Cleanup README.md
1 parent c47b980 commit 663f215

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

README.md

+15-14
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ The following steps describe how to create a JSON:API project with MongoDB.
3131
1. Configure MongoDB and JsonApiDotNetCore in `Program.cs`, seeding the database with sample data:
3232
```c#
3333
var builder = WebApplication.CreateBuilder(args);
34-
builder.Services.AddSingleton(_ => new MongoClient("mongodb://localhost:27017").GetDatabase("ExampleDbName"));
34+
builder.Services.AddSingleton(_ =>
35+
new MongoClient("mongodb://localhost:27017").GetDatabase("ExampleDbName"));
3536
builder.Services.AddJsonApi(options =>
3637
{
3738
options.UseRelativeLinks = true;
@@ -74,19 +75,6 @@ The following steps describe how to create a JSON:API project with MongoDB.
7475
}
7576
```
7677

77-
> [!TIP]
78-
> If your API project uses MongoDB only (so not in combination with EF Core), then instead of
79-
> registering all MongoDB resources and repositories individually, you can use:
80-
>
81-
> ```c#
82-
> builder.Services.AddJsonApi(facade => facade.AddCurrentAssembly());
83-
> builder.Services.AddJsonApiMongoDb();
84-
>
85-
> builder.Services.AddScoped(typeof(IResourceReadRepository<,>), typeof(MongoRepository<,>));
86-
> builder.Services.AddScoped(typeof(IResourceWriteRepository<,>), typeof(MongoRepository<,>));
87-
> builder.Services.AddScoped(typeof(IResourceRepository<,>), typeof(MongoRepository<,>));
88-
> ```
89-
9078
1. Start your API
9179
```bash
9280
dotnet run
@@ -137,6 +125,19 @@ The following steps describe how to create a JSON:API project with MongoDB.
137125

138126
</details>
139127

128+
> [!TIP]
129+
> If your API project uses MongoDB only (so not in combination with EF Core), then instead of
130+
> registering all MongoDB resources and repositories individually, you can use:
131+
>
132+
> ```c#
133+
> builder.Services.AddJsonApi(facade => facade.AddCurrentAssembly());
134+
> builder.Services.AddJsonApiMongoDb();
135+
>
136+
> builder.Services.AddScoped(typeof(IResourceReadRepository<,>), typeof(MongoRepository<,>));
137+
> builder.Services.AddScoped(typeof(IResourceWriteRepository<,>), typeof(MongoRepository<,>));
138+
> builder.Services.AddScoped(typeof(IResourceRepository<,>), typeof(MongoRepository<,>));
139+
> ```
140+
140141
## Using client-generated IDs
141142
142143
Resources that inherit from `HexStringMongoIdentifiable` use auto-generated (high-performance) 12-byte hexadecimal

0 commit comments

Comments
 (0)