Uploaded image for project: 'Realm Studio'
  1. Realm Studio
  2. RSTUDIO-519

Don't set null properties on class instance creation (noisy in mongo db)

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Is your feature request related to a problem? Please describe.

      When I create an instance of a class in Realm studio, all nullable fields I don't fill in are automatically filled in with null value (instead of not filling it). It's a lot of noise when you navigate in Mongo Compass

      Describe the solution you'd like

      Don't set null fields and have a way to unset a field in the table edition

      Describe alternatives you've considered

      Script to delete null properties (probably not optimised)

      const collectionNames = db.getCollectionNames();
      
      for (const name of collectionNames) {
        var coll = db.getCollection(name);
        var cursor = coll.find();
        while (cursor.hasNext()) {
          var doc = cursor.next();
          var keys = {};
          var hasNull = false;
          for (var x in doc) {
            if (x != "_id" && doc[x] == null) {
              keys[x] = 1;
              hasNull = true;
            }
          }
          if (hasNull) {
            coll.updateOne({ _id: doc._id }, { $unset: keys });
          }
        }
      }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: