Skip to content

Commit

Permalink
More examples in Mongo (golang-migrate#268)
Browse files Browse the repository at this point in the history
* adding/removing a new field in the schema

* example of updating field value from other fields

* added new line at end of files

Co-authored-by: Dale Hui <[email protected]>
  • Loading branch information
orasik and dhui committed Jan 3, 2020
1 parent f6d44b4 commit 3001e74
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
16 changes: 16 additions & 0 deletions database/mongodb/examples/migrations/003_add_new_field.down.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"update": "users",
"updates": [
{
"q": {},
"u": {
"$unset": {
"status": ""
}
},
"multi": true
}
]
}
]
16 changes: 16 additions & 0 deletions database/mongodb/examples/migrations/003_add_new_field.up.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"update": "users",
"updates": [
{
"q": {},
"u": {
"$set": {
"status": "active"
}
},
"multi": true
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"update": "users",
"updates": [
{
"q": {},
"u": {
"fullname": ""
},
"multi": true
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"aggregate": "users",
"pipeline": [
{
"$project": {
"_id": 1,
"firstname": 1,
"lastname": 1,
"username": 1,
"password": 1,
"email": 1,
"active": 1,
"fullname": { "$concat": ["$firstname", " ", "$lastname"] }
}
},
{
"$out": "users"
}
],
"cursor": {}
}
]

0 comments on commit 3001e74

Please sign in to comment.