Skip to content

alexx384/sqlForMongoDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task description

In Java, write a mini version of the translator from SQL to the MongoDB shell commands.

The input translator receives a string with an SQL query and returns a string with the MongoDB command. Example SELECT * FROM sales LIMIT 10 -> db.sales.find({}).limit(10)

  • It is enough to support only SELECT queries
  • The list of columns in SELECT must be translated into the projection of the find command: SELECT name, surname FROM collection -> db.collection.find({}, {name: 1, surname: 1})
  • SKIP/OFFSET and LIMIT are translated into the corresponding functions of MongoDB cursors: SELECT * FROM collection OFFSET 5 LIMIT 10 -> db.collection.find({}).skip(5).limit(10)
  • Predicates in WHERE turn into predicates of the find command: SELECT * FROM customers WHERE age > 22 -> db.customers.find({age: {$gt: 22}})
  • Implement only comparison operations: = <> <>. If there are several predicates, then they are connected by the AND operation

Do not forget to write tests.

About

simple translator from SQL to Mongodb shell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages