-
Notifications
You must be signed in to change notification settings - Fork 20
(DOCSP-29260): Migrate from KMongo #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
source/migrate-kmongo.txt
Outdated
.. tab:: | ||
:tabid: {+driver-long+} | ||
|
||
You can serialize data classes in the Kotlin driver using the ``kotlinx.serialization`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: You can use either automatic data class codecs or kotlinx serialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
.. _kotlin-migrate-kmongo: | ||
|
||
=================== | ||
Migrate from KMongo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Migrate the right word?
This is more a comparison between the two
a1f24dd
to
42d4329
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approving with some small suggestions that I think would help the refine the page
It is also a wrapper around the Java driver. | ||
It was created prior to the creation of the official Kotlin driver to serve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: no changes needed, but suggest combining these sentences to improve flow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
by wrapping the :driver:`MongoDB Java driver </java-drivers/>`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this PR necessarily, but S: move all FAQ entries to top level, right now all but the first are nested under the first even though they are not subsections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird. Corrected
for working with MongoDB from Kotlin applications. | ||
It is also a wrapper around the Java driver. | ||
It was created prior to the creation of the official Kotlin driver to serve | ||
the needs of the Kotlin community. As of July 2023, it has been marked as deprecated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: move the deprecation notice into an important admontition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
// Insert a document | ||
val jedi =a Jedi("Luke Skywalker", 19) | ||
collection.insertOne(jedi) | ||
|
||
// Find a document | ||
val luke = collection.find(Jedi::name.name, "Luke Skywalker") | ||
val jedis = collection.find(lt(Jedi::age.name, 30)).toList() | ||
|
||
// Update a document | ||
val filter = Filters.eq(Jedi::name.name, "Luke Skywalker") | ||
val update = Updates.set(Jedi::age.name, 20) | ||
collection.updateOne(filter, update) | ||
|
||
// Delete a document | ||
val filter = Filters.eq(Jedi::name.name, "Luke Skywalker") | ||
collection.deleteOne(filter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: remove unneeded indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
Aggregation pipelines can be built using the ``aggregate`` method and the | ||
``pipeline`` function: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aggregation pipelines can be built using the ``aggregate`` method and the | |
``pipeline`` function: | |
You can build aggregation pipelines by using the ``aggregate`` method and the | |
``pipeline`` function: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: In general, change from passive to active second person where possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
.. code-block:: kotlin | ||
|
||
data class Jedi(val name: String) | ||
|
||
val yoda = col.findOne(Jedi::name eq "Yoda") | ||
|
||
// Compile error (2 is not a String) | ||
val error = col.findOne(Jedi::name eq 2) | ||
|
||
// Use property reference with instances | ||
val yoda2 = col.findOne(yoda::name regex "Yo.*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: fix indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
.. code-block:: kotlin | ||
|
||
import org.litote.kmongo.MongoOperator.lt | ||
import org.litote.kmongo.MongoOperator.match | ||
import org.litote.kmongo.MongoOperator.regex | ||
import org.litote.kmongo.MongoOperator.sample | ||
|
||
val yoda = col.findOne("{name: {$regex: 'Yo.*'}}")!! | ||
val luke = col.aggregate<Jedi>("""[ {$match:{age:{$lt : ${yoda.age}}}}, | ||
{$sample:{size:1}} | ||
]""").first() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S fix indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check all code blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
// Async operations | ||
val jedi =a Jedi("Luke Skywalker", 19) | ||
collection.insertOne(jedi) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S fix indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
// Async operations | ||
col.insertOne(Jedi("Luke Skywalker", 19)) | ||
val yoda : Jedi? = col.findOne(Jedi::name eq "Yoda") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S fix indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
✨ Staging URL: https://docs-mongodborg-staging.corp.mongodb.com/kotlin/docsworker-xlarge/master/ 🪵 Logs |
# Pull Request Info [PR Reviewing Guidelines](https://github.com/mongodb/docs-java/blob/master/REVIEWING.md) JIRA - https://jira.mongodb.org/browse/DOCSP-29260 Staging - https://docs-mongodbcom-staging.corp.mongodb.com/kotlin/docsworker-xlarge/docsp-29260-migrate/migrate-kmongo/ ## Self-Review Checklist - [ ] Is this free of any warnings or errors in the RST? - [ ] Did you run a spell-check? - [ ] Did you run a grammar-check? - [ ] Are all the links working? (cherry picked from commit a2c6ed7)
# Pull Request Info Miss from merged #92 JIRA - https://jira.mongodb.org/browse/DOCSP-29260 Staging - https://docs-mongodbcom-staging.corp.mongodb.com/kotlin/docsworker-xlarge/no-jira-fix-kmongo-includes/migrate-kmongo/ --------- Co-authored-by: Rea Rustagi <[email protected]> (cherry picked from commit f3dfc0e)
# Pull Request Info Miss from merged #92 JIRA - https://jira.mongodb.org/browse/DOCSP-29260 Staging - https://docs-mongodbcom-staging.corp.mongodb.com/kotlin/docsworker-xlarge/no-jira-fix-kmongo-includes/migrate-kmongo/ --------- Co-authored-by: Rea Rustagi <[email protected]>
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-29260
Staging - https://docs-mongodbcom-staging.corp.mongodb.com/kotlin/docsworker-xlarge/docsp-29260-migrate/migrate-kmongo/
Self-Review Checklist