
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.
Official Ruby client for GitDB - GitHub-backed NoSQL database.
Add this line to your application's Gemfile:
gem 'gitdb-client'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install gitdb-client
require 'gitdb_client'
# Create a client instance
client = GitDBClient.new('your-github-token', 'owner', 'repository')
# Check server health
client.health
# Create a collection
client.create_collection('users')
# Insert a document
document = {
name: 'John Doe',
email: 'john@example.com',
age: 30
}
id = client.insert('users', document)
puts "Inserted document with ID: #{id}"
# Find documents
query = {
age: { '$gte' => 25 }
}
documents = client.find('users', query)
puts "Found #{documents.length} documents"
# Update a document
update = { age: 31 }
client.update('users', id, update)
# Delete a document
client.delete('users', id)
You'll need a GitHub Personal Access Token with the following permissions:
repo
- Full control of private repositoriesworkflow
- Update GitHub Action workflowsCreate a token at: https://github.com/settings/tokens
require 'gitdb_client'
# Basic initialization
client = GitDBClient.new('token', 'owner', 'repo')
# With custom base URL (for self-hosted instances)
client = GitDBClient.new('token', 'owner', 'repo', 'http://localhost:7896')
# Create a new client
client = GitDBClient.new(token, owner, repo)
# Create client with custom URL
client = GitDBClient.new(token, owner, repo, 'http://localhost:7896')
# Check if server is healthy
client.health
# Create a collection
client.create_collection('users')
# List all collections
collections = client.list_collections
collections.each do |collection|
puts "Collection: #{collection['name']} (#{collection['count']} documents)"
end
# Delete a collection
client.delete_collection('users')
document = {
name: 'Alice',
email: 'alice@example.com',
age: 25
}
id = client.insert('users', document)
puts "Inserted with ID: #{id}"
# Find all documents
all_users = client.find('users', nil)
# Find with query
query = {
age: { '$gte' => 30 }
}
older_users = client.find('users', query)
# Find one document
user = client.find_one('users', query)
# Find by ID
user = client.find_by_id('users', 'document-id')
update = {
age: 26,
last_updated: '2024-01-01'
}
client.update('users', 'document-id', update)
# Delete by ID
client.delete('users', 'document-id')
# Delete multiple documents
query = {
age: { '$lt' => 18 }
}
deleted_count = client.delete_many('users', query)
# Insert multiple documents
documents = [
{ name: 'Alice', age: 25 },
{ name: 'Bob', age: 30 },
{ name: 'Charlie', age: 35 }
]
documents.each do |doc|
id = client.insert('users', doc)
end
# Update multiple documents
query = {
age: { '$gte' => 25 }
}
update = {
category: 'senior'
}
updated_count = client.update_many('users', query, update)
The Ruby client supports MongoDB-style query operators:
query = {}
# Equal
query[:age] = 30
# Greater than
query[:age] = { '$gt' => 25 }
# Greater than or equal
query[:age] = { '$gte' => 25 }
# Less than
query[:age] = { '$lt' => 50 }
# Less than or equal
query[:age] = { '$lte' => 50 }
# In array
query[:status] = { '$in' => ['active', 'pending'] }
# Not in array
query[:status] = { '$nin' => ['inactive', 'deleted'] }
# Logical AND
query[:'$and'] = [
{ age: { '$gte' => 18 } },
{ status: 'active' }
]
# Logical OR
query[:'$or'] = [
{ status: 'active' },
{ status: 'pending' }
]
The SDK provides comprehensive error handling:
begin
document = client.find_by_id('users', 'non-existent-id')
rescue GitDBError => e
puts "GitDB Error: #{e.message}"
puts "Status Code: #{e.status_code}"
rescue => e
puts "General Error: #{e.message}"
end
require 'httparty'
# Create custom HTTP client
http_client = HTTParty
http_client.timeout = 30
# Create GitDB client with custom HTTP client
client = GitDBClient.new('token', 'owner', 'repo', http_client: http_client)
# The client includes built-in retry logic for transient errors
# You can configure retry behavior if needed
client.max_retries = 3
client.retry_delay = 1
require 'gitdb_client'
class User
attr_accessor :id, :name, :email, :age, :status, :created_at
def initialize(name, email, age)
@name = name
@email = email
@age = age
@status = 'active'
@created_at = Time.now
end
def to_hash
{
name: @name,
email: @email,
age: @age,
status: @status,
created_at: @created_at
}
end
end
class UserManager
def initialize(token, owner, repo)
@client = GitDBClient.new(token, owner, repo)
end
def create_user(name, email, age)
user = User.new(name, email, age)
@client.insert('users', user.to_hash)
end
def find_user_by_email(email)
query = { email: email }
@client.find_one('users', query)
end
def update_user_status(user_id, status)
update = { status: status }
@client.update('users', user_id, update)
end
def get_active_users
query = { status: 'active' }
@client.find('users', query)
end
def delete_inactive_users
query = { status: 'inactive' }
@client.delete_many('users', query)
end
end
# Usage
user_manager = UserManager.new('your-token', 'owner', 'repo')
# Create user
user_id = user_manager.create_user('John Doe', 'john@example.com', 30)
# Find user
user = user_manager.find_user_by_email('john@example.com')
# Update status
user_manager.update_user_status(user_id, 'inactive')
# Get active users
active_users = user_manager.get_active_users
puts "Active users: #{active_users.length}"
require 'rspec'
require 'gitdb_client'
RSpec.describe GitDBClient do
describe '#new' do
it 'creates a client instance' do
client = GitDBClient.new('token', 'owner', 'repo')
expect(client).to be_a(GitDBClient)
end
end
describe '#insert and #find_by_id' do
it 'inserts and finds a document' do
client = GitDBClient.new('token', 'owner', 'repo')
# Test document
document = {
name: 'Test User',
age: 25
}
# Insert
id = client.insert('test', document)
# Find by ID
found = client.find_by_id('test', id)
expect(found['name']).to eq('Test User')
# Cleanup
client.delete('test', id)
end
end
end
Authentication Error
Repository Access
Network Issues
Rate Limiting
Enable debug mode to see detailed request/response information:
# Set debug mode (if supported by the client)
client.debug_mode = true
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Unknown package
We found that gitdb-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.