The C# .NET SDK currently only supports legacy versions of Nitric prior to v1. This version is maintained for compatibility with existing projects and not recommended for new projects. New projects should be started using a supported SDK (presented automatically using the `nitric new` command) orget in touch to request an update to the latest version.
.NET - Collection()
Creates a new Collection.
using Nitric.Sdk;
using Nitric.Sdk.Resource;
class Profile
{
public string Name { get; set; }
public float Age { get; set; }
}
var profiles = Nitric.Collection<Profile>("profiles").With(
CollectionPermission.Reading, CollectionPermission.Writing, CollectionPermission.Deleting
);
Nitric.Run();
Parameters
- Name
name
- Required
- Required
- Type
- string
- Description
The unique name of this Collection within the app. Subsequent calls to
Collection
with the same name will return the same object.
Access
All Nitric resources provide access permissions you can use to specify the level of access your code needs to the resource. See here for details Access Control documentation.
Available permissions:
CollectionPermission.Reading
This permission allows your code to read and query documents from the collection.
CollectionPermission.Writing
This permission allows your code to write documents to the collection.
CollectionPermission.Deleting
This permission allows your code to delete documents from the collection.
Examples
Create a collection
using Nitric.Sdk;
using Nitric.Sdk.Resource;
class Profile
{
public string Name { get; set; }
public float Age { get; set; }
}
var profiles = Nitric.Collection<Profile>("profiles").With(
CollectionPermission.Reading, CollectionPermission.Writing, CollectionPermission.Deleting
);
Nitric.Run();