question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove models with same set of field.

See original GitHub issue

It would be good if we can identify that a similar model exists and use that model instead of creating a new model, especially when the FIELDS and DATA-TYPE are same.

For example, when my data is as follows,

{
    "Arm Right": {
        "Joint 1": 5,
        "Joint 2": 3, 
        "Joint 3": 66
    }, 
    "Arm Left": {
        "Joint 1": 55,
        "Joint 2": 13, 
        "Joint 3": 6
    }
}

we get the following output,

class ArmRight(BaseModel):
    Joint_1: int = Field(..., alias='Joint 1')
    Joint_2: int = Field(..., alias='Joint 2')
    Joint_3: int = Field(..., alias='Joint 3')

class ArmLeft(BaseModel):
    Joint_1: int = Field(..., alias='Joint 1')
    Joint_2: int = Field(..., alias='Joint 2')
    Joint_3: int = Field(..., alias='Joint 3')

class Model(BaseModel):
    Arm_Right: ArmRight = Field(..., alias='Arm Right')
    Arm_Left: ArmLeft = Field(..., alias='Arm Left')

Describe the solution you’d like I think it would be good if we can detect that models for ArmLeft and ArmRight are the same, and then to just use one of these models. For example,

class ArmRight (BaseModel):
    Joint_1: int = Field(..., alias='Joint 1')
    Joint_2: int = Field(..., alias='Joint 2')
    Joint_3: int = Field(..., alias='Joint 3')

class Model(BaseModel):
    Arm_Right: ArmRight = Field(..., alias='Arm Right')
    Arm_Left: ArmRight = Field(..., alias='Arm Left')

Describe alternatives you’ve considered Currently, I just delete manually. But, we have a big system with many similar structures in JSON and many time we need to manually delete about 1000 models. 😦

Thank you very much for this excellent tool.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
koxudaxicommented, Jul 9, 2020

@gk-patel Thank you for creating this issue. I think it’s a good idea. The behavior may have to be an option of the command line 🤔

I will implement this feature after remove bugs.

0reactions
koxudaxicommented, Jan 7, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove a field in Django model - Stack Overflow
I set the uniqueness of the record on ClientId and PersNumber. I have created 3 records in the database. Along the way I...
Read more >
Delete a Data Model Object and Remove Mappings
You can delete a data model object (DMO) and remove data lake object (DLO) field mappings directly from the data mapping canvas.Required Editions...
Read more >
db.collection.remove() — MongoDB Manual
By default, remove() removes all documents that match the query expression. Specify the justOne option to limit the operation to removing a single...
Read more >
Models - Django documentation
Models ¶. A model is the single, definitive source of information about your data. It contains the essential fields and behaviors of the...
Read more >
Mongoose v6.8.0: Models
Compiling your first model; Constructing Documents; Querying; Deleting ... The first argument is the singular name of the collection your model is for....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found