Last active
November 21, 2021 18:20
-
-
Save blaugold/e7d05574161e64055639683c013e017f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<MutableDocument> createNote({ | |
required String title, | |
required String body, | |
}) async { | |
// In Couchbase Lite, data is stored in JSON like documents. The default | |
// constructor of MutableDocument creates a new document with a randomly | |
// generated id. | |
final doc = MutableDocument({ | |
// Since documents of different types are all stored in the same database, | |
// it is customary to store the type of the document in the `type` field. | |
'type': 'note', | |
'title': title, | |
'body': body, | |
}); | |
// Now save the new note in the database. | |
await database.saveDocument(doc); | |
return doc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment