Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
github.com/theapemachine/squeel
Squeel is a powerful SQL-to-MongoDB query translator that enables you to write MongoDB queries using familiar SQL syntax. It bridges the gap between SQL and MongoDB's query language, making it easier for developers familiar with SQL to work with MongoDB.
$lookup
go get github.com/fanfactory/data/squeel
import "github.com/fanfactory/data/squeel"
// Initialize a new statement
sql := "SELECT name, age FROM users WHERE age > 21 ORDER BY name DESC LIMIT 10"
statement := squeel.NewStatement(sql)
// Build the query
query := squeel.NewQuery()
query, err := statement.Build(query)
if err != nil {
log.Fatal(err)
}
// The resulting query object can be used with MongoDB driver
-- Simple SELECT
SELECT * FROM users
-- Select with UUID matching (automatically handles Binary conversion)
SELECT * FROM User WHERE _id = '695FF995-5DC4-4FBE-B80C-2621360D578F'
-- Select specific fields with conditions
SELECT first_name FROM user_profile WHERE _id = '695FF995-5DC4-4FBE-B80C-2621360D578F'
-- Pagination
SELECT * FROM fanchecks LIMIT 10 OFFSET 2
-- JOIN with aggregation
SELECT u.name, p.city
FROM users u
JOIN profiles p ON u.id = p.user_id
WHERE u.age > 25
-- Complex aggregation with GROUP BY, HAVING, and ORDER BY
SELECT department, AVG(salary) as avg_salary
FROM employees
WHERE hire_date >= '2020-01-01'
GROUP BY department
HAVING AVG(salary) > 50000
-- Pattern matching and complex conditions
SELECT * FROM products
WHERE name LIKE '%phone%'
AND (category = 'Electronics' OR category = 'Accessories')
AND price BETWEEN 100 AND 500
-- Nested field queries
SELECT * FROM questions WHERE theme.nl = 'Some Theme'
Squeel translates SQL queries into a Query
struct that can be used with the MongoDB driver:
type Query struct {
Context context.Context
Comment string
Operation string // "find", "findone", "aggregate", "count", "distinct"
Collection string
Filter bson.D
Projection bson.D
Sort bson.D
Limit *int64
Offset *int64
Pipeline mongo.Pipeline
Payload bson.D
}
find
: Regular SELECT queriesfindone
: SELECT with LIMIT 1aggregate
: Complex queries with JOIN, GROUP BY, or aggregation functionscount
: COUNT queriesdistinct
: SELECT DISTINCT queriesSqueel automatically handles UUID fields differently based on collection naming:
User
): UUIDs are converted to MongoDB Binary typeusers
): UUIDs remain as stringsContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to all contributors who have helped make Squeel better!
FAQs
Unknown package
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 supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.