Skip to content

(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

Merged
merged 7 commits into from
Jul 28, 2023

Conversation

cbullinger
Copy link
Collaborator

@cbullinger cbullinger commented Jun 16, 2023

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

  • 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?

@cbullinger cbullinger added the Try to Have Try to have for .local NYC label Jun 19, 2023
@cbullinger cbullinger requested a review from rozza June 19, 2023 11:19
.. tab::
:tabid: {+driver-long+}

You can serialize data classes in the Kotlin driver using the ``kotlinx.serialization``
Copy link
Member

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.

Copy link
Collaborator Author

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
Copy link
Member

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

@cbullinger cbullinger force-pushed the docsp-29260-migrate branch from a1f24dd to 42d4329 Compare July 28, 2023 11:38
@cbullinger cbullinger marked this pull request as ready for review July 28, 2023 11:39
Copy link
Contributor

@rustagir rustagir left a 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

Comment on lines +3 to +4
It is also a wrapper around the Java driver.
It was created prior to the creation of the official Kotlin driver to serve
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines 26 to 27
by wrapping the :driver:`MongoDB Java driver </java-drivers/>`.

Copy link
Contributor

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

Copy link
Collaborator Author

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.
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines +98 to +113
// 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: remove unneeded indentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Comment on lines +115 to +116
Aggregation pipelines can be built using the ``aggregate`` method and the
``pipeline`` function:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines +221 to +231
.. 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.*")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: fix indentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines +236 to +246
.. 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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S fix indentation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check all code blocks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines +439 to +442
// Async operations
val jedi =a Jedi("Luke Skywalker", 19)
collection.insertOne(jedi)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S fix indentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines +505 to +508
// Async operations
col.insertOne(Jedi("Luke Skywalker", 19))
val yoda : Jedi? = col.findOne(Jedi::name eq "Yoda")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S fix indentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@cbullinger cbullinger merged commit a2c6ed7 into mongodb:master Jul 28, 2023
@docs-builder-bot
Copy link
Collaborator

cbullinger added a commit that referenced this pull request Jul 28, 2023
# 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Try to Have Try to have for .local NYC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants