
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
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 mongodb-model 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.