mb-vqb-core
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -45,3 +45,3 @@ "use strict"; | ||
var mongoUriNoDb = _a.mongoUriNoDb, database = _a.database, collection = _a.collection, importsList = _a.importsList, refFunctionList = _a.refFunctionList, query = _a.query, $projection = _a.$projection, $sort = _a.$sort, $skip = _a.$skip, $limit = _a.$limit, hasOptions = _a.hasOptions, isAggr = _a.isAggr; | ||
return "using MongoDB.Bson;\nusing MongoDB.Driver;\nusing System;\nusing System.Threading.Tasks;\n\nnamespace MongoDBQueryCode\n{\n class Program\n {\n" + (refFunctionList.join("\n") + " ") + "static async Task _Main()\n {\n //MongoDefaults.GuidRepresentation = MongoDB.Bson.GuidRepresentation.Standard;\n var client = new MongoClient(" + JSON.stringify(mongoUriNoDb) + ");\n var database = client.GetDatabase(" + JSON.stringify(database) + ");\n var collection = database.GetCollection<BsonDocument>(" + JSON.stringify(collection) + ");\n\n //Created with MongoBoooter, the essential IDE for MongoDB - https://www.mongobooster.com\n " + getVarPart(isAggr, query, hasOptions) + (_.isEmpty($projection) ? "" : "\n var projection = " + alignStringify($projection) + ";") + (_.isEmpty($sort) ? "" : "\n var sort = " + alignStringify($sort) + ";") + (!hasOptions ? "" : "\n var options = new FindOptions<BsonDocument>()\n {\n " + getOptionsPart({ $projection: $projection, $sort: $sort, $skip: $skip, $limit: $limit }) + "\n };") + " \n\n" + (isAggr ? | ||
return "using MongoDB.Bson;\nusing MongoDB.Driver;\nusing System;\nusing System.Threading.Tasks;\n\nnamespace MongoDBQueryCode\n{\n class Program\n {\n" + (refFunctionList.join("\n") + " ") + "static async Task _Main()\n {\n //MongoDefaults.GuidRepresentation = MongoDB.Bson.GuidRepresentation.Standard;\n var client = new MongoClient(" + JSON.stringify(mongoUriNoDb) + ");\n var database = client.GetDatabase(" + JSON.stringify(database) + ");\n var collection = database.GetCollection<BsonDocument>(" + JSON.stringify(collection) + ");\n\n //Created with NoSQLBooster, the essential IDE for MongoDB - https://nosqlbooster.com\n " + getVarPart(isAggr, query, hasOptions) + (_.isEmpty($projection) ? "" : "\n var projection = " + alignStringify($projection) + ";") + (_.isEmpty($sort) ? "" : "\n var sort = " + alignStringify($sort) + ";") + (!hasOptions ? "" : "\n var options = new FindOptions<BsonDocument>()\n {\n " + getOptionsPart({ $projection: $projection, $sort: $sort, $skip: $skip, $limit: $limit }) + "\n };") + " \n\n" + (isAggr ? | ||
" var results =await collection.Aggregate<BsonDocument>(pipeline).ToListAsync(); \n\n foreach (var document in results)\n {\n Console.WriteLine(document.GetElement(\"_id\"));\n }" : | ||
@@ -48,0 +48,0 @@ " using (var cursor = await collection.FindAsync(filter" + (!hasOptions ? "" : " , options") + "))\n {\n while (await cursor.MoveNextAsync())\n {\n var batch = cursor.Current;\n foreach (var document in batch)\n {\n Console.WriteLine(document.GetElement(\"_id\"));\n }\n }\n }\n") + " \n }\n\n static void Main(string[] args)\n {\n _Main().Wait();\n }\n }\n}"; |
@@ -47,3 +47,3 @@ "use strict"; | ||
var mongoUriNoDb = _a.mongoUriNoDb, database = _a.database, collection = _a.collection, importsList = _a.importsList, refFunctionList = _a.refFunctionList, query = _a.query, _b = _a.$projection, $projection = _b === void 0 ? undefined : _b, _c = _a.$sort, $sort = _c === void 0 ? undefined : _c, _d = _a.$skip, $skip = _d === void 0 ? undefined : _d, _e = _a.$limit, $limit = _e === void 0 ? undefined : _e, throwParseException = _a.throwParseException, isAggr = _a.isAggr; | ||
return "import com.mongodb.Block;\nimport com.mongodb.MongoClient;\nimport com.mongodb.MongoClientURI;\nimport com.mongodb.MongoException;\nimport com.mongodb.client.MongoCollection;\nimport com.mongodb.client.MongoDatabase;\nimport org.bson.Document;" + (isAggr ? "\nimport java.util.List;\n" : "") + "\n" + importsList.join("\n") + "\n\npublic class MongoQueryCode {\n" + (_.isEmpty(refFunctionList) ? "" : "\n" + refFunctionList.join("\n\n")) + " \n public static void main(String[] args)" + (throwParseException ? " throws ParseException " : "") + "{\n try {\n MongoClientURI connectionString = new MongoClientURI(" + JSON.stringify(mongoUriNoDb) + ");\n MongoClient mongoClient = new MongoClient(connectionString); \n \n MongoDatabase database = mongoClient.getDatabase(" + JSON.stringify(database) + ");\n MongoCollection<Document> collection = database.getCollection(" + JSON.stringify(collection) + ");\n \n //Created with MongoBoooter, the essential IDE for MongoDB - https://www.mongobooster.com\n " + getQueryVarPart(isAggr, query) + (_.isEmpty($projection) ? "" : " Document projection = " + stringify($projection, { space: 16 }) + ";\n") + (_.isEmpty($sort) ? "" : " Document sort = " + stringify($sort, { space: 16 }) + ";\n") + "\n Block<Document> printBlock = new Block<Document>() {\n @Override\n public void apply(final Document document) {\n System.out.println(document.get(\"_id\"));\n }\n };\n \n " + getMethodPart(isAggr, query) + (_.isEmpty($projection) ? "" : ".projection(projection)") + (_.isEmpty($sort) ? "" : ".sort(sort)") + ($skip > 0 ? ".skip(" + $skip + ")" : "") + ($limit > 0 ? ".limit(" + $limit + ")" : "") + ".forEach(printBlock);\n \n } catch (MongoException e) {\n // handle MongoDB exception\n }\n }\n}"; | ||
return "import com.mongodb.Block;\nimport com.mongodb.MongoClient;\nimport com.mongodb.MongoClientURI;\nimport com.mongodb.MongoException;\nimport com.mongodb.client.MongoCollection;\nimport com.mongodb.client.MongoDatabase;\nimport org.bson.Document;" + (isAggr ? "\nimport java.util.List;\n" : "") + "\n" + importsList.join("\n") + "\n\npublic class MongoQueryCode {\n" + (_.isEmpty(refFunctionList) ? "" : "\n" + refFunctionList.join("\n\n")) + " \n public static void main(String[] args)" + (throwParseException ? " throws ParseException " : "") + "{\n try {\n MongoClientURI connectionString = new MongoClientURI(" + JSON.stringify(mongoUriNoDb) + ");\n MongoClient mongoClient = new MongoClient(connectionString); \n \n MongoDatabase database = mongoClient.getDatabase(" + JSON.stringify(database) + ");\n MongoCollection<Document> collection = database.getCollection(" + JSON.stringify(collection) + ");\n \n //Created with NoSQLBooster, the essential IDE for MongoDB - https://nosqlbooster.com\n " + getQueryVarPart(isAggr, query) + (_.isEmpty($projection) ? "" : " Document projection = " + stringify($projection, { space: 16 }) + ";\n") + (_.isEmpty($sort) ? "" : " Document sort = " + stringify($sort, { space: 16 }) + ";\n") + "\n Block<Document> printBlock = new Block<Document>() {\n @Override\n public void apply(final Document document) {\n System.out.println(document.get(\"_id\"));\n }\n };\n \n " + getMethodPart(isAggr, query) + (_.isEmpty($projection) ? "" : ".projection(projection)") + (_.isEmpty($sort) ? "" : ".sort(sort)") + ($skip > 0 ? ".skip(" + $skip + ")" : "") + ($limit > 0 ? ".limit(" + $limit + ")" : "") + ".forEach(printBlock);\n \n } catch (MongoException e) {\n // handle MongoDB exception\n }\n }\n}"; | ||
}; | ||
@@ -50,0 +50,0 @@ function stringify(obj, opt) { |
@@ -8,15 +8,15 @@ "use strict"; | ||
var mongoUri = _a.mongoUri, collection = _a.collection, importsList = _a.importsList, refFunctionList = _a.refFunctionList, clause = _a.clause; | ||
return "var mongodb = require(\"mongodb\");//npm i mongodb@2\n" + (importsList.map(function (it) { return "var " + it + "=mongodb." + it + ";"; }).join("\n") + "\n") + "\n" + refFunctionList.join("\n") + "\n\nvar client = mongodb.MongoClient;\n\nclient.connect(" + JSON.stringify(mongoUri) + ", function (err, db) {\n \n var cursor = db.collection(" + JSON.stringify(collection) + ")" + clause + ";\n \n // Created with MongoBoooter, the essential IDE for MongoDB - https://www.mongobooster.com\n cursor.toArray(function(err, docs) {\n if (err) throw err;\n console.log(docs.map(function(it){return it._id}));\n db.close();\n });\n});"; | ||
return "var mongodb = require(\"mongodb\");//npm i mongodb@2\n" + (importsList.map(function (it) { return "var " + it + "=mongodb." + it + ";"; }).join("\n") + "\n") + "\n" + refFunctionList.join("\n") + "\n\nvar client = mongodb.MongoClient;\n\nclient.connect(" + JSON.stringify(mongoUri) + ", function (err, db) {\n \n var cursor = db.collection(" + JSON.stringify(collection) + ")" + clause + ";\n \n //Created with NoSQLBooster, the essential IDE for MongoDB - https://nosqlbooster.com\n cursor.toArray(function(err, docs) {\n if (err) throw err;\n console.log(docs.map(function(it){return it._id}));\n db.close();\n });\n});"; | ||
}; | ||
var es6tmpl = function (_a) { | ||
var mongoUri = _a.mongoUri, collection = _a.collection, importsList = _a.importsList, refFunctionList = _a.refFunctionList, clause = _a.clause; | ||
return "const mongodb=require(\"mongodb\");//npm i mongodb@2\nconst {" + ["MongoClient"].concat(importsList).join(",") + "}=mongodb;\n\n" + refFunctionList.join("\n") + "\n\n// Created with MongoBoooter, the essential IDE for MongoDB - https://www.mongobooster.com\nMongoClient.connect(" + JSON.stringify(mongoUri) + ").then((db)=> {\n return db.collection(" + JSON.stringify(collection) + ")" + clause + "\n .toArray()\n .then((docs)=>{\n console.log(docs.map(it=>it._id));\n db.close();\n })\n }).catch(err=>{\n console.error(err);\n});"; | ||
return "const mongodb=require(\"mongodb\");//npm i mongodb@2\nconst {" + ["MongoClient"].concat(importsList).join(",") + "}=mongodb;\n\n" + refFunctionList.join("\n") + "\n\n//Created with NoSQLBooster, the essential IDE for MongoDB - https://nosqlbooster.com\nMongoClient.connect(" + JSON.stringify(mongoUri) + ").then((db)=> {\n return db.collection(" + JSON.stringify(collection) + ")" + clause + "\n .toArray()\n .then((docs)=>{\n console.log(docs.map(it=>it._id));\n db.close();\n })\n }).catch(err=>{\n console.error(err);\n});"; | ||
}; | ||
var es7tmpl = function (_a) { | ||
var mongoUri = _a.mongoUri, collection = _a.collection, importsList = _a.importsList, refFunctionList = _a.refFunctionList, clause = _a.clause; | ||
return "const mongodb=require(\"mongodb\");//npm i mongodb@2\nconst {" + ["MongoClient"].concat(importsList).join(",") + "}=mongodb;\n\n" + refFunctionList.join("\n") + "\n\n// Created with MongoBoooter, the essential IDE for MongoDB - https://www.mongobooster.com\nasync function main(){\n const db=await MongoClient.connect(" + JSON.stringify(mongoUri) + ");\n const docs=await db.collection(" + JSON.stringify(collection) + ")" + clause + "\n .toArray();\n \n console.log(docs.map(it=>it._id));\n\n db.close();\n}\n\nmain()"; | ||
return "const mongodb=require(\"mongodb\");//npm i mongodb@2\nconst {" + ["MongoClient"].concat(importsList).join(",") + "}=mongodb;\n\n" + refFunctionList.join("\n") + "\n\n//Created with NoSQLBooster, the essential IDE for MongoDB - https://nosqlbooster.com\nasync function main(){\n const db=await MongoClient.connect(" + JSON.stringify(mongoUri) + ");\n const docs=await db.collection(" + JSON.stringify(collection) + ")" + clause + "\n .toArray();\n \n console.log(docs.map(it=>it._id));\n\n db.close();\n}\n\nmain()"; | ||
}; | ||
var es7Driver3xtmpl = function (_a) { | ||
var mongoUriNoDb = _a.mongoUriNoDb, database = _a.database, collection = _a.collection, importsList = _a.importsList, refFunctionList = _a.refFunctionList, clause = _a.clause; | ||
return "const mongodb=require(\"mongodb\");//npm i mongodb\nconst {" + ["MongoClient"].concat(importsList).join(",") + "}=mongodb;\n\n" + refFunctionList.join("\n") + "\n\n// Created with MongoBoooter, the essential IDE for MongoDB - https://www.mongobooster.com\nasync function main(){\n const client=await MongoClient.connect(" + JSON.stringify(mongoUriNoDb) + ");\n const db=client.db(" + JSON.stringify(database) + ")\n const docs=await db.collection(" + JSON.stringify(collection) + ")" + clause + "\n .toArray();\n \n console.log(docs.map(it=>it._id));\n\n client.close();\n}\n\nmain()"; | ||
return "const mongodb=require(\"mongodb\");//npm i mongodb\nconst {" + ["MongoClient"].concat(importsList).join(",") + "}=mongodb;\n\n" + refFunctionList.join("\n") + "\n\n//Created with NoSQLBooster, the essential IDE for MongoDB - https://nosqlbooster.com\nasync function main(){\n const client=await MongoClient.connect(" + JSON.stringify(mongoUriNoDb) + ");\n const db=client.db(" + JSON.stringify(database) + ")\n const docs=await db.collection(" + JSON.stringify(collection) + ")" + clause + "\n .toArray();\n \n console.log(docs.map(it=>it._id));\n\n client.close();\n}\n\nmain()"; | ||
}; | ||
@@ -23,0 +23,0 @@ function nodejsStringify(_a) { |
@@ -38,3 +38,3 @@ "use strict"; | ||
var mongoUriNoDb = _a.mongoUriNoDb, database = _a.database, collection = _a.collection, importsList = _a.importsList, query = _a.query, _b = _a.$projection, $projection = _b === void 0 ? undefined : _b, _c = _a.$sort, $sort = _c === void 0 ? undefined : _c, _d = _a.$skip, $skip = _d === void 0 ? undefined : _d, _e = _a.$limit, $limit = _e === void 0 ? undefined : _e, isAggr = _a.isAggr; | ||
return (_.isEmpty(importsList) ? "" : importsList.join("\n") + "\n") + "from pymongo import MongoClient\n\nclient = MongoClient(" + JSON.stringify(mongoUriNoDb) + ")\ndatabase = client[" + JSON.stringify(database) + "]\ncollection = database[" + JSON.stringify(collection) + "]\n" + emptyOr(isAggr ? "pipeline" : "query", query) + emptyOr("projection", JSON.stringify($projection, null, 4)) + emptyOr("sort", _.isEmpty($sort) ? "" : "[" + _.keys($sort).map(function (k) { return "(" + JSON.stringify(k) + ", " + $sort[k] + ")"; }) + "]") + "\n\n# Created with MongoBoooter, the essential IDE for MongoDB - https://www.mongobooster.com\ncursor = " + getMethodPart({ isAggr: isAggr, query: query, $projection: $projection, $limit: $limit, $skip: $skip, $sort: $sort }) + "\ntry:\n for doc in cursor:\n print doc[\"_id\"]\nfinally:\n cursor.close()\n"; | ||
return (_.isEmpty(importsList) ? "" : importsList.join("\n") + "\n") + "from pymongo import MongoClient\n\nclient = MongoClient(" + JSON.stringify(mongoUriNoDb) + ")\ndatabase = client[" + JSON.stringify(database) + "]\ncollection = database[" + JSON.stringify(collection) + "]\n" + emptyOr(isAggr ? "pipeline" : "query", query) + emptyOr("projection", JSON.stringify($projection, null, 4)) + emptyOr("sort", _.isEmpty($sort) ? "" : "[" + _.keys($sort).map(function (k) { return "(" + JSON.stringify(k) + ", " + $sort[k] + ")"; }) + "]") + "\n\n# Created with NoSQLBooster, the essential IDE for MongoDB - https://nosqlbooster.com\ncursor = " + getMethodPart({ isAggr: isAggr, query: query, $projection: $projection, $limit: $limit, $skip: $skip, $sort: $sort }) + "\ntry:\n for doc in cursor:\n print doc[\"_id\"]\nfinally:\n cursor.close()\n"; | ||
}; | ||
@@ -41,0 +41,0 @@ function pythonStringify(_a) { |
@@ -26,3 +26,3 @@ "use strict"; | ||
CodeGenType["ShellJs"] = "MongoDB Shell"; | ||
//FluentShellJs = "MongoBooster Fluent shell js", | ||
//FluentShellJs = "NoSQLBooster Fluent shell js", | ||
CodeGenType["NodeJS3xAsync"] = "Node.js ES7 Async/Await (3.x driver)"; | ||
@@ -29,0 +29,0 @@ CodeGenType["NodeJS"] = "Node.js ES5 (2.x driver)"; |
{ | ||
"name": "mb-vqb-core", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "mb query core, internal project", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
131552