ruby_mongo_utils 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +27 -3
- data/lib/mongo_utils/version.rb +1 -1
- data/{mongo_utils.gemspec → ruby_mongo_utils.gemspec} +0 -0
- data/spec/fixtures/page.rb +0 -2
- metadata +2 -4
- data/mongodumps/mongo_utils_tests/pages.bson +0 -0
- data/mongodumps/mongo_utils_tests/pages.metadata.json +0 -1
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Ruby Mongo Utilities
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem '
|
9
|
+
gem 'ruby_mongo_utils'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -14,11 +14,35 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install
|
17
|
+
$ gem install ruby_mongo_utils
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
### Stripable
|
22
|
+
|
23
|
+
Include MongoUtils::Stripable in your classes in order to prevent stroring nil, [], {}, 0, false in the Mongo!
|
24
|
+
|
25
|
+
class Page
|
26
|
+
include MongoUtils::Stripable
|
27
|
+
end
|
28
|
+
|
29
|
+
## MongoDump and MongoRestore
|
30
|
+
|
31
|
+
Provide MongoDump with collection name, query and a path in order to backup entries:
|
32
|
+
|
33
|
+
MongoUtils::MongoDump.call(
|
34
|
+
collection: Page.collection_name,
|
35
|
+
query: "{ 'page_type': { '\\$ne': 'Wordpress' } }",
|
36
|
+
path: "#{Rails.root}/mongodumps"
|
37
|
+
)
|
38
|
+
|
39
|
+
Provide MongoRestore with collection name, filter and a path in order to restore matching entries:
|
40
|
+
|
41
|
+
MongoUtils::MongoRestore.call(
|
42
|
+
collection: Page.collection_name,
|
43
|
+
filter: "{ 'page_type': 'Facebook' }",
|
44
|
+
path: "#{Rails.root}/mongodumps"
|
45
|
+
)
|
22
46
|
|
23
47
|
## Contributing
|
24
48
|
|
data/lib/mongo_utils/version.rb
CHANGED
File without changes
|
data/spec/fixtures/page.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_mongo_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -77,9 +77,7 @@ files:
|
|
77
77
|
- lib/mongo_utils/mongo_restore.rb
|
78
78
|
- lib/mongo_utils/stripable.rb
|
79
79
|
- lib/mongo_utils/version.rb
|
80
|
-
-
|
81
|
-
- mongodumps/mongo_utils_tests/pages.bson
|
82
|
-
- mongodumps/mongo_utils_tests/pages.metadata.json
|
80
|
+
- ruby_mongo_utils.gemspec
|
83
81
|
- spec/fixtures/page.rb
|
84
82
|
- spec/fixtures/post.rb
|
85
83
|
- spec/mongo_utils/mongo_restore_spec.rb
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
{indexes:[{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "mongo_utils_tests.pages", "name" : "_id_" }]}
|