Automatically set the created and updated date with squeryl? - scala

I remember seeing a trait that will automatically add the created and updated dates when using either lift's Record or Mapper ORMs.
The question is, is there a similar thing for Squeryl to automatically set the date/time the record was inserted and, less importantly, the last date/time it was updated?
If not, is it possible to make one?

There is no existing trait you can mix in to do it, but if you are using 0.9.5-SNAPSHOT you can create your own using Squeryl's lifecycle callbacks. Take a look at this message for more info: https://groups.google.com/forum/#!searchin/squeryl/lifecycle/squeryl/8FY7n0DN5fs/O2O8OhqVPSUJ. If you run into any trouble post a message to the group and we'll do what we can to help you out.

Related

Change or override automatic "update" timestamp of Vapor 4 model

I have a model in my Vapor app that has a timestamp that gets automatically updated to the current time whenever the model gets modified:
#Timestamp(key: "last_modification_date", on: .update, format: .unix)
var lastModificationDate: Date?
I find this feature to be incredibly useful because one can never forget to update the timestamp.
However, there is one case in the entire app where it would be really handy if I could modify the model without changing this value (or set it manually to a value other than the current time). Is this possible somehow?
So far I found nothing about this in the documentation or anywhere on the internet. Any help would be very much appreciated!
Unfortunately there's no way to workaround the timestamp logic in Fluent. If you want to modify a model without setting the update field you'll need to drop down to SQLKit or a raw query

Reset TFDMemTable to default (no field definitions) at Runtime

I have a raw TFDMemTable at design time. I only activate the same at runtime and simultaneously display data through a grid component. The fields will be defined at runtime depending of its source (API REST) and user case.
At runtime, I need to reset the TFDMemTable to its default. Meaning, remove all the fields definition and accept another fresh data and field definitions.
Currently, the fields set by the first ran during runtime was fixed and it is not accepting any new field definitions. I am contemplating on creating TFDMemTable at runtime but I still have to figure out. I am hoping there is a better way..
Real quick question: How can I reset the TFDMemTable to its default at runtime (no fields definition)?
UPDATE 1:
TFDMemTable will receive JSON data from API. This API throws data with unknown number of columns/fields. Meaning, it can only determine the fields upon received of JSON data. Hence, I'd like that each time I called API, the TFDMemTable should redefine all the fields to be able to capture the API fields.
So, from my understanding, if I could be able to reset the TFDMemTable I could avoid this issue.
You can use TFDMemTable.ClearFields to remove all of the existing field definitions.

Visio 2013: How to trigger a change in databinding of all shapes

I have a nice process overview for our ordering process in Visio. I have an external data source (SQL Server), which works fine. Every record in my data source represents one ordering process. Currently all my shapes of the process are linked to the first record of the data source.
Now I want to add a dynamic behavior. What I want to achieve is this:
A user provides the order reference in a textbox (order reference is a column in the data source)
Afterwards the user clicks a button
After the button click, the process is updated and all shapes are now linked to the external data source record, that matches the provided order reference
So in short: the user should be able to select which process that needs to be visualized.
I assume that this is common functionality, but I don't see how I can deal with this requirement. I've searched already some days on this issue, but without any success.
Can you help me with this issue?
Thanks a lot!
Problem solved :-)
Some old school VBA was required. Using the DataRecordSet object did the trick. It contains a method GetDataRowIDs that you can use to query the external dataset. Once you have the record to visualize, it's just a matter of dynamically updating the shapes with the correct record. Use macro recording to see how to do this.
MSDN: http://msdn.microsoft.com/en-us/library/office/ms195694(v=office.12).aspx

SugarCRM - Will workflow works during importing of files?

I would like to ask if there is a relationship between the Workflow and Importing of Files.
For example, the execution of workflow occurs when a record is saved, and it applies to updated records. And the action is to update a certain field on the target module if a specific field is changed. Say for example, Field A is updated to YES if field B is changed.
So it works well, when I manually saved the module after updating the field B.
How about during importing? Will the workflow would still matter? Provided that all conditions were successfully met.
I hope you could help me on this. I need to update our TS if there's a need for hard coding to support this.
Actually I have already posted this on the sugar forums. :D
Thanks so much!
Workflows are triggered with a before_save logic hook.
Logic hooks are triggered anytime the save() function is called
Creating records via the import process calls the the save() function.
So, yes, importing records will trigger your workflows.
The short answer is yes. There is no long answer.
Sugar uses the SugarBean class to save records, and it handles workflow. So if you save through Sugar, import, or use web services they all use SugarBean so therefore handle workflow.

Determining whether mongodb save method really update a record or not

My question is clear as in the title. When a request come to my service for updating related record in mongoDb, we use "save" method.
However, I would like to understand whether the save method really updates the record or not.
In other words, I would like to know if the content going to save is the same with the existing content in mongoDb. Accordingly, even if save method is executed without any errors, is it possible to understand whether it is really updated or not?
Thanks in advance
There are several ways to checks this.
The first is after calling Save, is to call the getLastError method. Within the console this is just db.getLastError().
This will tell you if an error occurred during the last operation. More details can be found at te following address http://docs.mongodb.org/manual/core/write-operations/#write-concern.
Another way would be to call findAndModify, this will allow you to update the document and either get the updated document back.
http://docs.mongodb.org/manual/reference/command/findAndModify/
Both of these are available in all of the official drivers.
Save method always writes the record.
There is no situation in Mongo where the write would not happen because the record that is being saved is identical to the record that's already there. The write would simply happen and "overwrite" existing data with new data (which happens to be identical).
The only way you can tell is by comparing the old and new documents - and that's a lot of extra work.