Mongo.insert_one
You're seeing just the function
insert_one
, go back to Mongo module for more information.
Specs
insert_one(GenServer.server(), collection(), BSON.document(), Keyword.t()) :: result(Mongo.InsertOneResult.t())
Insert a single document into the collection.
If the document is missing the _id
field or it is nil
, an ObjectId
will be generated, inserted into the document, and returned in the result struct.
Examples
Mongo.insert_one(pid, "users", %{first_name: "John", last_name: "Smith"})
{:ok, session} = Session.start_session(pid)
Session.start_transaction(session)
Mongo.insert_one(pid, "users", %{first_name: "John", last_name: "Smith"}, session: session)
Session.commit_transaction(session)
Session.end_session(pid)