• L
    Style improvements on MongoDB example (#20515) · bad14484
    Laura Beatris 提交于
    I've looked at the example code and saw some consistent issues related to code style. The changes applied to this PR fixes the following points:
    
    - Differences of line breaks styles between multiple files
    - Differences of if statements styles
    - Unnecessary comment
    - A typo on a JSDocs
    
    ---
    
    There were line breaks between statements on `pages/index.js`
    ````
    export async function getServerSideProps(context) {
      const { client } = await connectToDatabase()
    
      const isConnected = await client.isConnected() 
    
      return {
        props: { isConnected },
      }
    }
    ```` 
    
    And this wasn't being applied to the MongoDB utility:
    
    ````
    export async function connectToDatabase() {
      if (cached.conn) return cached.conn
      if (!cached.promise) {
        const conn = {}
        const opts = {
          useNewUrlParser: true,
          useUnifiedTopology: true,
        }
    {...}
    ````
    
    And also, as shown in the snippet above, there are different styles of if statements being used. 
    
    With that being said, the reason I made this PR is because I think that this kind of inconsistent arises questions when a contributor looks to the codebase, even if this is a simple example. 
    bad14484
index.js 5.5 KB