Skip to content
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

Support Updates to a collection #290

Open
xendren opened this issue Sep 14, 2022 · 7 comments
Open

Support Updates to a collection #290

xendren opened this issue Sep 14, 2022 · 7 comments
Assignees

Comments

@xendren
Copy link

xendren commented Sep 14, 2022

It appears that the extension is missing the ability to update a collection. How is everyone else on the planet solving the absence of updates while still using Liquibase for automated mongoldb deployments? This is to be a huge feature missing from the extension.

@Nida96
Copy link

Nida96 commented Sep 22, 2022

Completely agree, can we have an update on when can we expect this functionality or if there is any workaround for this at the moment?

@Nida96
Copy link

Nida96 commented Sep 22, 2022

Just like we have examples for insertOne() and insertMany() https://docs.liquibase.com/install/tutorials/mongodb.html.
There should be methods to support updateMany() and updateOne()

@DanZDatical
Copy link

DanZDatical commented Sep 22, 2022

While there is not a bespoke change type for updates, you can do updates by leveraging the runCommand change type in a changeset. It follows the pattern from Mongo's runCommand() function, so for update, the example here: https://www.mongodb.com/docs/manual/reference/command/update/

For example:

<changeSet id="findAndModify_car2" author="someone">
      <ext:runCommand>
          <ext:command>
                {
                  findAndModify: "car",
                  query: { name: "Honda", color: "Silver", cno:"H415" ,speed: 25 },
                  sort: { cno: 1 },
                  update: { $inc: { speed: 20 } },
                  upsert: true,
                  new: true
                  }
            </ext:command>
         </ext:runCommand>
		 <rollback>
			<ext:runCommand>
				<ext:command>
                                       {
                                           delete: "car",
			                    deletes: [ {
				                  q: { name: "Honda" },
				                 limit: 0
				                         }
				                   ]
                                          }
				</ext:command>
			</ext:runCommand>
		 </rollback>
   </changeSet>

@kevin-atx kevin-atx self-assigned this Sep 23, 2022
@Nida96
Copy link

Nida96 commented Oct 4, 2022

Any plan on providing support for this without runCommand() ?

@DanZDatical
Copy link

We are planning that plan right now and looking at different ways to do that.

How do you envision an instruction such as this being handled?
For example, would it be better to have the ability to "Do it the same as in Compass or mongosh" or "Do it with a specialized Liquibase Changetype"?

We would love to hear your thoughts.

@oliallan14
Copy link

You can do most of what is needed with runCommand or adminCommand. These make the specific operators such as insertMany() redundant.

However, similar to plain SQL changes for relational systems (https://www.liquibase.com/blog/plain-sql) it could be neat to have plain-MQL feature added

@xendren
Copy link
Author

xendren commented Nov 16, 2022

I am not seeing the value of using Liquibase for MongoDB if I have to build my own update solution around the runCommand. For consistency, I would just build my solution to use the runCommand for all activities. The only thing I would be missing is the change log management that Liquibase provides, but that is all arbitrary in this context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Open Issues
Development

No branches or pull requests

6 participants