Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop' of https://github.com/Elfocrash/Cosmonaut into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
Elfocrash committed Dec 13, 2018
2 parents a7e45e9 + ccb9e34 commit 25b92e9
Showing 1 changed file with 50 additions and 12 deletions.
62 changes: 50 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ var user = await cosmoStore.QueryMultipleAsync("select * from c w.Firstname = @n
```

#### Collection sharing
Cosmonaut is all about making the integration with CosmosDB easy as well as making things like cost optimisation part of the library.
Cosmonaut is all about making integrating with Cosmos DB easy as well as making things such as cost optimisation part of the library.

That's why Cosmonaut support collection sharing between different types of entities.
That's why Cosmonaut supports transparent collection sharing between different types of entities.

Why would you do that?

Expand All @@ -104,7 +104,54 @@ The `EntityName` will be used to make the object identifiable for Cosmosnaut. Be

Once you set this up you can add individual CosmosStores with shared collections.

##### Pagination

#### Collection naming

Your collections will automatically be named based on the plural of the object you are using in the generic type.
However you can override that by decorating the class with the `CosmosCollection` attribute.

Example:
```csharp
[CosmosCollection("somename")]
```

By default you are required to specify your collection name in the attribute level shared entities like this:

```c#
[SharedCosmosCollection("shared")]
public class Car : ISharedCosmosEntity
{
public string Id { get; set; }
public string CosmosEntityName { get; set; }
}
```

Even though this is convinient I understand that you might need to have a dynamic way of setting this.
That's why the `CosmosStore` class has some extra constructors that allow you to specify the `overriddenCollectionName` property. This property will override any collection name specified at the attribute level and will use that one instead.

Note: If you have specified a `CollectionPrefix` at the `CosmosStoreSettings` level it will still be added. You are only overriding the collection name that the attribute would normally set.

Example

Class implementation:
```c#
[SharedCosmosCollection("shared")]
public class Car : ISharedCosmosEntity
{
public string Id { get; set; }
public string CosmosEntityName { get; set; }
}
```

CosmosStore initialisation:
```c#
var cosmosStore = new CosmosStore<Car>(someSettings, "oldcars");
```

The outcome of this would be a collection named `oldcars` becase the `shared` collection name is overriden in the constructor.
There are also method overloads for the same property at the dependency injection extension level.

#### Pagination

Cosmonaut supports two types of pagination.

Expand Down Expand Up @@ -257,15 +304,6 @@ Partitions are great but you should these 3 very important things about them and

More on the third issue here [Unique keys in Azure Cosmos DB](https://docs.microsoft.com/en-us/azure/cosmos-db/unique-keys)

#### Collection naming
Your collections will automatically be named based on the plural of the object you are using in the generic type.
However you can override that by decorating the class with the `CosmosCollection` attribute.

Example:
```csharp
[CosmosCollection("somename")]
```

### Logging

#### Event source
Expand Down

0 comments on commit 25b92e9

Please sign in to comment.