-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VSCODE-183: Edit documents from collection #239
VSCODE-183: Edit documents from collection #239
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - tried it out, works well. If we want we could show a different message when a user tries to edit a document from a view, but I think how it is currently is fine (it says document cannot be found). Couple small questions
@@ -21,8 +21,9 @@ MongoDB Playgrounds are the most convenient way to prototype and execute CRUD op | |||
|
|||
- Prototype your queries, aggregations, and MongoDB commands with MongoDB syntax highlighting and intelligent autocomplete for MongoDB shell API, MongoDB operators, and for database, collection, and field names. | |||
- Run your playgrounds and see the results instantly. Click the play button in the tab bar to see the output. | |||
- Save your playgrounds in your workspace and use them to document how your application interacts with MongoDB | |||
- Build aggregations quickly with helpful and well-commented stage snippets | |||
- Edit documents returned by your playground. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
throw new Error(errorMessage); | ||
} | ||
|
||
const find = util.promisify(dataservice.find.bind(dataservice)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
export enum DocumentSource { | ||
DOCUMENT_SOURCE_TREEVIEW = 'treeview', | ||
DOCUMENT_SOURCE_PLAYGROUND = 'playground', | ||
DOCUMENT_SOURCE_COLLECTIONVIEW = 'collectionview' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we already have a few enums
and types
in the util folder. Maybe there's a better place we can have them - is the source only used by telemetry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we use it for telemetry, but in order to make it work, we need to pass it to several places in code. And I found it weird to require a telemetry model in types.ts to import this enum therefore moved it to a separate file. I also have noticed that we have types in type.js, but also separate files with types such as connectionModelType.ts or dataServiceType.ts. I think it would be nice to place all of them together. Eiter all in a single types file or each type into a separate file and place, all types files to a single types folder. But I think to do it after discussion with you as a small separate PR. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure sounds good
sinon.replace(vscode.workspace, 'openTextDocument', mockOpenTextDocument); | ||
|
||
const mockShowTextDocument = sinon.fake.resolves(); | ||
const mockShowTextDocument: any = sinon.fake(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the sinon fake type work here? we might be able to avoid some of the any
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing with this any
that when we import Sinon instead of requiring it, linter starts complaining about additional things and sinon.SinonSpy
that fits here for the sinon.replace(vscode.workspace, 'showTextDocument', mockShowTextDocument);
replacement starts erroring with Property 'firstArg' does not exist on type 'SinonSpy<any[], any>
. We can revisit this later and try to find something better than the any
type, but for now, I think it is ok to use any
, since before it was without a type anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha sounds good. Will be nice to get rid of some of the any
s one day. Importing things with their types is a good start. Maybe firstArg
is an internal thing or something we shouldn't be using 🤔 should be fine to handle it another time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe everything is ok with firstArg
, but we need to figure out how to property create mocks with typescript and Sinon. I was reading the internet about it and looks like it worked with the earlier versions of typescript and start erroring at some point.
I have a question about this feature. From the readme and the screenshot added in #241 it seems that I should be able to write a query in a playground, and then edit the result, but when I try to edit the result, I get a message saying that I can't edit in a read-only editor. I'm using version 0.4.2 of the plugin, so I'm curious what I might be doing wrong that I am not able to edit the playground result. |
@localjo hey, just wanted to ask you to check the code lens setting, but you found it first 😀 thx for trying the extension! and feel free to reach out in the future if you have any other questions! |
Description
Provide the ability to edit documents from the collection view so that when a user is looking at a collection they can quickly make changes to the documents without having to go through playgrounds.
Document Edited
andDocument Updated
telemetry events.https://jira.mongodb.org/browse/VSCODE-183
Checklist
Motivation and Context
Types of changes