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.Doc.Set()
Set the value of a document.
using Nitric.Sdk;
using Nitric.Sdk.Resources;
var profiles = Nitric.Collection<Profile>("profiles").With(CollectionPermission.Writing);
var drakesProfile = profiles.Doc("Drake Mallard").Set(
new Profile {
Name = "Drake Mallard"
Age = 28.0,
}
);
Nitric.Run();
Parameters
- Name
document
- Required
- Required
- Type
- object
- Description
The document to set on the key
Examples
Set a document
using Nitric.Sdk;
using Nitric.Sdk.Resources;
var profiles = Nitric.Collection<Profile>("profiles").With(CollectionPermission.Writing);
var drakesProfile = profiles.Doc("Drake Mallard").Set(
new Profile {
Name = "Drake Mallard"
Age = 28.0,
}
);
Nitric.Run();
Update a document
using Nitric.Sdk;
using Nitric.Sdk.Resources;
var profiles = Nitric.Collection<Profile>("profiles").With(CollectionPermission.Reading, CollectionPermission.Writing);
var drakesProfile = profiles.Doc("Drake Mallard");
var exitingProfile = drakesProfile.Get();
existingProfile.Age = 29.0;
drakesProfile.Set(existingProfile);
Nitric.Run();