mongodb-js / vscode

Connect to MongoDB and Atlas and directly from your VS Code environment, navigate your databases and collections, inspect your schema and use playgrounds to prototype queries and aggregations.
https://marketplace.visualstudio.com/items?itemName=mongodb.mongodb-vscode
Apache License 2.0
327 stars 58 forks source link

Write playground as TypeScript file #604

Open DemianParkhomenko opened 11 months ago

DemianParkhomenko commented 11 months ago

Feature Request

It would be nice to write MongoDB playground in Typescript, then we will have design time validation and good suggestions in IDE.

Detailed Description

It would be awesome to have types for MongoDB interfaces and the ability to import your own types.

import {Sale} from './types';

use('mongodbVSCodePlaygroundDB');

const sales: Sale[] = [
  { 'item': 'abc', 'price': 10, 'quantity': 2, 'date': new Date('2014-03-01T08:00:00Z') },
  { 'item': 'jkl', 'price': 20, 'quantity': 1, 'date': new Date('2014-03-01T09:00:00Z') },
  { 'item': 'xyz', 'price': 5, 'quantity': 10, 'date': new Date('2014-03-15T09:00:00Z') },
  { 'item': 'xyz', 'price': 5, 'quantity': 20, 'date': new Date('2014-04-04T11:21:39.736Z') },
  { 'item': 'abc', 'price': 10, 'quantity': 10, 'date': new Date('2014-04-04T21:23:13.331Z') },
  { 'item': 'def', 'price': 7.5, 'quantity': 5, 'date': new Date('2015-06-04T05:08:13Z') },
  { 'item': 'def', 'price': 7.5, 'quantity': 10, 'date': new Date('2015-09-10T08:43:00Z') },
  { 'item': 'abc', 'price': 10, 'quantity': 5, 'date': new Date('2016-02-06T20:20:13Z') },
]

db.getCollection('sales').insertMany(sales);

Possible Implementation

We can define global.d.ts for MongoDB db gloabls as use, db and transpile the file into js before running.

alenakhineika commented 8 months ago

Hey, this should be a nice feature to have! Could you post your idea on our feedback forum so people can vote for it? This will help us prioritize the work.

DemianParkhomenko commented 8 months ago

Hey, this should be a nice feature to have! Could you post your idea on our feedback forum so people can vote for it? This will help us prioritize the work.

Yes, of course. I'll add it

DemianParkhomenko commented 8 months ago

Hey, this should be a nice feature to have! Could you post your idea on our feedback forum so people can vote for it? This will help us prioritize the work.

Done

https://feedback.mongodb.com/forums/929236-mongodb-for-vs-code/suggestions/47715974-write-playground-as-typescript-file

fbgoat commented 2 months ago

Any update on this?

alenakhineika commented 2 months ago

Please vote for this feature on the feedback forum to help us prioritize this work ⬆️