
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
Object Model for MongoDB (callbacks, validations, mass-assignment, finders, ...).
Other ODM usually try to cover simple but non-standard API of MongoDB behind complex ORM-like abstractions. This tool exposes simplicity and power of MongoDB and leverages it's differences.
# Connecting to MongoDB.
require 'mongo/model'
Mongo.defaults.merge! symbolize: true, multi: true, safe: true
connection = Mongo::Connection.new
db = connection.db 'default_test'
db.units.drop
Mongo::Model.db = db
# Let's define the game unit.
class Unit
inherit Mongo::Model
collection :units
attr_accessor :name, :status, :stats
scope :alive, status: 'alive'
class Stats
inherit Mongo::Model
attr_accessor :attack, :life, :shield
end
end
# Create.
zeratul = Unit.build(name: 'Zeratul', status: 'alive', stats: Unit::Stats.build(attack: 85, life: 300, shield: 100))
tassadar = Unit.build(name: 'Tassadar', status: 'dead', stats: Unit::Stats.build(attack: 0, life: 80, shield: 300))
zeratul.save
tassadar.save
# Udate (we made error - mistakenly set Tassadar's attack as zero, let's fix it).
tassadar.stats.attack = 20
tassadar.save
# Querying first & all, there's also :each, the same as :all.
Unit.first name: 'Zeratul' # => zeratul
Unit.all name: 'Zeratul' # => [zeratul]
Unit.all name: 'Zeratul' do |unit|
unit # => zeratul
end
# Simple finders (bang versions also availiable).
Unit.by_name 'Zeratul' # => zeratul
Unit.first_by_name 'Zeratul' # => zeratul
Unit.all_by_name 'Zeratul' # => [zeratul]
# Scopes.
Unit.alive.count # => 1
Unit.alive.first # => zeratul
# Callbacks & callbacks on embedded models.
# Validations.
# Save model to any collection.
Source: examples/model.rb
FAQs
Unknown package
We found that mongodbmodel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.