mongocore 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2398fe451c3d58b40b9a635a4e5cd365a702cc3
4
- data.tar.gz: 2e3f32a1f68b45543e75b5dfd9c607d7c81e682a
3
+ metadata.gz: ad5f759d0098c30be1771c2f96dc97b16d3f3f3c
4
+ data.tar.gz: 2e427d8c0bfbb4e878e592b28caf2fa4ae089fd5
5
5
  SHA512:
6
- metadata.gz: 33843a29724bfcdb0e2e61a9ec9cf4bfae5df8990c1ab250c7bc1a0f8426e9997b53622476fbe553f7a397df3edd311038c13b6582e304358e952a87336a31c6
7
- data.tar.gz: 6dfae14f09cf37cc1eafd82fd4920e37c676f3682f1ccf1f6fa9bc2b892c910c4a68a72426b9af13eba9ae383bef63ad52c569084a2e4865f72d5ddcf762ba9f
6
+ metadata.gz: 9cacabc91e2e7a783ee9766e4fd1328c7609c71ff78a76343f96e7bc1dfb73b1e329db3417ca0333edc098acd9d59612916cd59bb261c93bc942653ec9d8eb7a
7
+ data.tar.gz: 0b6d23cebdc0a0c9f5d7a4bdea56eaba1819f688782bf72db8c29fd4ce4d5fd202b64c9a1e2675ab9019722e3abc2e72ad963ca7ce885a146c5d26edac790d45
@@ -234,7 +234,7 @@ module Mongocore
234
234
  return false unless valid? if o[:validate]
235
235
 
236
236
  # Create a new query
237
- filter(type){one.update(attributes).ok?}
237
+ filter(type){one.send((@saved ? :update : :insert), attributes).ok?}
238
238
  end
239
239
 
240
240
  end
@@ -291,7 +291,10 @@ module Mongocore
291
291
  find({}, {}, :fields => o)
292
292
  end
293
293
 
294
-
294
+ # Insert
295
+ def insert(a = {}, o = {})
296
+ new(a).tap{|r| r.save(o)}
297
+ end
295
298
  # # # # # # # # #
296
299
  # After, before and validation filters
297
300
  # Pass a method name as symbol or a block
@@ -56,6 +56,11 @@ module Mongocore
56
56
  @collection.find(@query, @options).projection(@store[:fields]).skip(@store[:skip]).sort(@store[:sort]).limit(@store[:limit])
57
57
  end
58
58
 
59
+ # Insert
60
+ def insert(a)
61
+ @collection.insert_one(a.delete_if{|k, v| v.nil?})
62
+ end
63
+
59
64
  # Update
60
65
  def update(a)
61
66
  # We do $set on non nil, $unset on nil
data/lib/mongocore.rb CHANGED
@@ -7,7 +7,7 @@ require 'mongo'
7
7
  require 'request_store'
8
8
 
9
9
  module Mongocore
10
- VERSION = '0.1.6'
10
+ VERSION = '0.1.7'
11
11
 
12
12
  # # # # # #
13
13
  # Mongocore Ruby Database Driver.
data/mongocore.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'mongocore'
3
- s.version = '0.1.6'
3
+ s.version = '0.1.7'
4
4
  s.date = '2017-10-21'
5
5
  s.summary = "MongoDB ORM implementation on top of the Ruby MongoDB driver"
6
6
  s.description = "Does validations, associations, scopes, filters, pagination, counter cache, request cache, and nested queries. Using a YAML schema file, which supports default values, data types, and security levels for each key."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongocore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fugroup Limited