I'm trying to get breeze working with hand generated Metadata, but I can't seem to find documentation covering navigation properties through matrix tables.
the data model is:
Organization
PK:OrganizationID
User
PK:UserID
The table that joins them is:
User_Organization
PK:UserOrganizationID
FK:OrganizationID
FK:UserID
When I retrieve an Organization I want it to have a property "users" which contains an array of User objects.
How do I define this and specify the matrix table in Breeze Metadata, seeing as User does not have an organizationID?
** update
My primary problem is that I'm linking Breeze to Sequelize, so I need to be able to manage this all through the metadata if possible. The first answer below from #Jeremy-Danyow solves the problem with client side code, but I'm looking for a way to present the final object graph to breeze as part of the metadata.
I think this question might be a duplicate of Many-to-many relations in Breeze. There is useful information in the answer there as well as the comments on the answer.
That said, I want to propose a work-around for this part of your question:
When I retrieve an Organization I want it to have a property "users" which contains an array of User objects.
If you were to configure your metadata the supported way you could add a read-only "users" property to your organization entity like this:
function Organization() { }
Organization.prototype.users = function () {
return this.userOrganizations().map(function(userOrganization) { return userOrganization.user() });
};
store.registerEntityTypeCtor('Organization', Organization);
This uses the "Add methods to the constructor" approach documented here.
Edit
Sounds like breeze-sequelize support is in the works and will be released soon. See here and here. If you can afford to wait a little bit you'll have less friction getting this going.
Related
I have a .stp file that has random integer name values for model names in the Model Browser but a valid (ie. human readable) Component Name. I would like to replace the default name with the Component Name in the Model Browser for these cases.
I've looked at a couple similar posts on SO but nothing has worked for me as yet (here and here). I'm using version 6.3.1 of the viewer.
In my investigation into where the data is stored, I've found a strings array in the InstanceTree as well as a PropDbLoader (in the ViewerPropertyPanel). The strings array seems to get populated with the name data (in an interesting ASCII array look-up setup) and the PropDbLoader has properties for the models. The name for the model in the Model Browser popup looks to come from within the ModelStructureTreeDelegate class (InstanceTree.getNodeName). I'd like to be able to extend or override the getNodeName and populate it with Component Name but I have (as of yet) not found a way to get at this data in the model tree.
Any insight or direction would be greatly appreciated
Basically you will need to extend/override the default DIV creation behaviour for model tree nodes here and customize to your needs:
ModelStructureTreeDelegate.prototype.createTreeNode
See here for code sample.
i've been using Firebase for a couple of months now, and it's been great along with angularjs and anfularfire, before i explain the problem, let me give you a fast background: i am currently using different controllers for an app that is meant for users to register plant species and to use them as items to create an interactive garden. In order to save the database from any controller, i stored the reference into the $scope
var rootRef = firebase.database().ref();
$scope.database = $firebaseObject(rootRef)
so when i want to make a change or add an object, i do it like this:
$scope.example_function = function(i){//supposing 'i' is a string
$scope.element[e] = i //supposing that 'e' contains a string
$scope.database.$save()
}
Sometimes this works, other times it just doesn't save the firebase, specially when editing existing objects inside the database or adding an element to an specific object. It's really frustrating because it doesn't throw an error or something, i even tried deleting the path i wanted to change and then storing it again with the new info. Also i tried with local references to the database in each controller, but nope... Anyone knows how else can i make this work?
Also. I am pretty sure the connection between the database and the app is fine, i got to store lots of species by now, the problem is when i want to edit the info from the species or add an url to get an image.
I don't think it's a good idea to bind your entire database to a the scope. It will be extremely hard to scale.
Remember that when you request for a ref and send it to $firebaseObject it will register to change events and this will start sync of your entire database which might potentially be huge.
For the issues you're experiencing, it looks like you're binding the database reference to a database property of $scope but in your example_function you're applying values to an element property. So maybe the fix you're looking for is something like:
function example_function(i) {
$scope.database.element = i;
$scope.database.$save();
}
I am looking for a library for form building based on provided model, so we are looking at formly:)
I took a glance into the examples and video on formly web site, but there are still some questions without
an answer.
-There are a lot of examples of viewing/editing single entity via formly. I am interested in some example of viewing/editing collection of entities via formly (being displayed e.g. as a table). Each field of table should have it's own type.
-Editing single entity is cool. But what if editing one entity requires creation of the other entity. E.g. what if you create "User" entity, and you need to create/choose existing "Bank Account" entity to link with User? What is the best way to do such a thing?
-Are there any examples of client + server applications using formly? (e.g, we get forms from server side?). Maybe, some attributes (annotations) to classes, fields for automatic formly objects generation?
You can do all the things your talking about with formly. If you need help with something specific, follow the instructions at http://help.angular-formly.com
Okay so I'm trying to make a custom elgg website.
One of the main features I need is for users to be able to create events, and for those events to be displayed in a sortable table.
For events, I use a plugin for elgg called Event Manager. I originally thought that the data for the events was stored in mysql, but apparently it's stored in the elgg API instead.
'
Can anyone give me any tips on where to find the event data, and how to pull it from the api and put it into a javascript/html table?
Gracias,
Pablo Escobar
Regarding details of writing plugins, refer to documentation: http://docs.elgg.org/wiki/Main_Page and make sure to read through: http://docs.elgg.org/wiki/Engine/DataModel
To get event_calendar events, you'll need to use one of the functions from elgg_get_entities family. You'll most likely need to filter by type (object) and subtype (event_calendar), apply some filtering (metadata_name_value_pairs parameter to elgg_get_entities_from_metadata) and sorting (order_by_metadata)
For additional support you'll be more successful at community.elgg.org page.
I am a newbie at NetSuite scripting. It looks like a normal EDIT or UPDATE function is not at all normal in the Netsuite. There are APIs for creating and deleting record like nlapiCreateRecord and nlapiDeleteRecord, but nowhere in the documentation I could find the way to edit and update the existing record. I have restrictions on using PHP.
I have created a custom TFC customer form (server side js), which should be able to fetch the data and update if required. I have been able to fetch the records as of now, but please tell me how to update an existing record?
To be a little more precise, use nlapiLoadRecord to fetch the record from the database. Set the fields as needed. Use nlapiSubmitRecord to save it.
Untested code off the top of my head:
var record = nlapiLoadRecord('record_type_goes_here', internal_id_of_record_goes_here);
record.setFieldValue('field_internal_id_goes_here', 'value to set goes here);
nlapiSubmitRecord(record);
Fill in the appropriate values where needed.
For the benefit of anyone looking at this question who is concerned with performance, it is much more efficient to use
nlapiSubmitField(type, id, fields, values, doSourcing)
If you know exactly what you are updating. This is both faster than submitRecord, and avoids the often significant overhead of loading the record first.
The function used to edit an existing record is nlapiSubmitRecord. See definition here http://suitecoder.appspot.com/static/api.html