Creating Dynamic model and store in sencha touch - sencha-touch-2.1

I want to create dynamic model in Sencha from a xml file that contains the fields.Please tell me how to create a dynamic model and register it in app.js and if you can post Any sample application it would be a kind help.

You can create a store to read the fields form the xml file.
Then you can create a model with fields you loaded.
Last, create a store to read by the model.

Related

back4app data model relationship filtering

I use back4app as my backend environment which is almost similar to Parse.
I would like to ask a few questions regarding organising data models relationships. Let me add a few words about my structure:
I have a User data model and a Project data model. Project can contain many User records. When I want to put a user to a project I wrap it to another data model called ProjectUser. I need this for separating levels when a User can be a part of entire system and when a User can be just a part of smaller things such as Project component I've described.
ProjectUser class has a User and Project as Relation (not sure do I need to use Pointer here):
So now looks like I can filter ProjectUser using Project key and get all needed users in appropriate project.
My question do I need to use such approach with filtering or do I need to add a new column to Project class with Array type and append this array every time I put new ProjectUser to a destination project? Can my Project class just contain array of another custom classes?
To summarise:
Do I need to use pointers instead of relations?
Is this better to create additional object with two custom classes in it (ProjectUser) or it's ok to use an array in Project data model to retrieve all Users or ProjectUsers.
UP
Faced the same question
have back4app as backend ad table to filter by related object (User).

Fields from another table in Laravel Nova

Laravel Nova 3.8. How can I create a new fields in a resource that will be saved to another table when the resource is updated? Without creating a second resource. Is it possible? Didn't find this in the documentation
You can declare fields in resource and after that use YourModelObserver saving method to create some data in another table from request

Remove or Add an attribute to CoreData at runtime programmatically

I have to create and remove attributes based on an api response in Objective C.
For example, Now my api response contains fields "facebook", "whatsapp" and "viber". But in future the reponse can add "youtube". Based on this response, I have to remove all the attributes and values of an entity "Social", and create Four attributes now and set values.
How to do that programmatically? Because the default *.xcdatamodeld file cant help me here, right?
Note: My project is in objective C.
The data model is mutable when the app starts-- you can completely build the model in code, and not use the model editor, for example. But as soon as you load a persistent store file, you must treat the model as fixed. Any changes after loading a persistent store will cause crashes. That means any changes would have to happen before calling either loadPersistentStores(completionHandler:) or addPersistentStore(with:completionHandler:).
Alexander's suggestion of optional attributes is a good one. If you need the model to be more dynamic, you would need to create a new related entity which would store the service name plus whatever information you need to save about the service. If you did this, your Social entity would have a to-many relationship to a new entity called something like Service. Service would have a string property called name that would have values like twitter, facebook, youtube, etc. It would also have whatever other attributes you need to save about the service.
You can create all 4 fields in advance and just make them optional and fill them depending on the server response. But you cannot add new attributes in runtime. Your *.xcdatamodeld file compiles into *.momd and it contains all the data to create tables in the DB since Core Data by default works with SQLite under the hood and it's a relational database management system.
To make attributes optional you should check that.
And then newly created objects contain nil as default values of object properties. So, in your case your "youtube" property of Social object will be just nil.

How can I create a Form Definition using REST API in Orbeon?

I could update and publish existing form definitions in Orbeon:
When you create, edit, or read form definition with Form Builder, form definitions are stored as Form Builder data. That is, they are stored under: /crud/orbeon/builder/data/[FORM_DATA_ID]. On the other hand, when Form Builder publishes a form definition, it stores it where Form Runner will find it, that is under: /crud/[APPLICATION_NAME]/[FORM_NAME]/form. For example, this is what happens when saving and publishing a form definition acme/demo with a single attachment.
However, I don't know how to create a new Form Definition using REST API. Can someone please provide me an example of the REST call for creating a new form definition?
Most likely, the easiest way is to create an empty form in Form Builder, save it, and then retrieve the XML stored in the orbeon_form_data table in the newly added row, in the xml column (assuming you're using a relational database). Then, with that XML in hand, you can write your own code that creates a new row through the CRUD API.
Also, RFE 3080 covers an enhancement that might make this easier for you. It was written with creating new instances of forms you created in Form Builder mind, not new instances of a form definition, but in essence the idea is the same.

Is it a bad idea to save/process a file in a Custom Model Binder?

I am trying to figure out the best way to handle a file upload for my model.
I have an object in my entity layer that has a filename field to store information about an uploaded file that is saved to the file system. I do not want to create a property on my object for HttpPostedFileBase.
Typically, I would add another parameter to my action for the uploaded file and then manually copy it to my object. However, all of this happens in my controller after the default model binding has taken place.
I am thinking that I could create a custom model binder that processes the upload stream, resizes the image and saves it to the drive. It will then set the property of the object to have the correct filename.
Does this seem like a bad practice? Any better ideas? I do not really want to setup a ViewModel just for this postback as all of my data annotations are on my entity object.

Resources