.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();

See also

Last updated on Oct 11, 2024