Python - collection.doc.set()

Set the value of a document.

from nitric.resources import collection
enemies = collection('profiles').allow('writing')
drakes_profile = profiles.doc('Drake Mallard')
await drakes_profile.set({
firstName: 'Drake',
lastName: 'Mallard',
})

Parameters

  • Name
    document
    Required
    Required
    Type
    object
    Description

    The document to set on the key.

Examples

Set a document

from nitric.resources import collection
enemies = collection('profiles').allow('writing')
drakesProfile = profiles.doc('Drake Mallard')
await drakesProfile.set({
firstName: 'Drake',
lastName: 'Mallard',
})

Update a document

from nitric.resources import collection
profiles = collection('profiles').allow('reading','writing')
drakesProfile = profiles.doc('Drake Mallard')
await drakesProfile.get()
await drakesProfile.set({
firstName: 'Drake',
lastName: 'Mallard',
})

See also

Last updated on Dec 24, 2024