I know you can soft delete in Doctrine (i.e. do not delete a record but rather add a "deleted" value). There's an extension for that.
Now I wonder if there's a way to "soft update" a record. I mean not actually update the record but rather create a new record and make the old one invalid. In the same extension as soft-delete, there's a function loggable, but this one logs to a different table.
I could create a controller that, instead of updating, soft-deletes
(and thus invalidates) the old record, and then creates a new one
with the new values. But I'm unsure if this is a good practice.
Maybe I should create this action on the object itself? But I'm
unsure how to do this.
Edit
I've looked into Versionable and EntityAudit (as suggested by Tomas), but it seems these bundles do way too much. I merely want to check if a given field is different from the old one, and if not: soft-delete the old one (I'm using softDeleteable so a simple remove() will do); then create a new one with the changed values.
So ideally it would lurk in the shadows until an update is performed. Then read from the mapping configuration which fields it needs to watch, and if these fields are indeed different from what's persisted, the program should execute the remove() and persist() commands.
This extension might suit your use case:
simplethings/EntityAudit
It records any changes you want to track.
So it should be pretty easy to modify it to meed your needs.
Related
I am using gocb library. I want to update specific field of a document.
However if the document does not exist, I don't want to do anything I will just produce an error message.
You can say that first retrieve the full document itself and make update and then insert it.It is possible right. But I want to use a ready for use method for this purpose if there is any. Since I don't want to retrieve the document. I just want to update some fields of it.
Is there a way for this in gocb library?
If you want to update parts of the document, you can look at sub-document operations. It only transmits the accessed sections of the document over the network making it more efficient for small changes.
Example: https://couchbase.live/examples/basic-go-subdoc-mutate
If you want to rewrite the entire document, you are looking for Replace() which replaces an existing document with a new one. It is similar to Upsert() except that it can only replace existing documents & not create new ones.
General Reference:https://docs.couchbase.com/server/current/guides/updating-data.html
I'm using VS2013 in a MVC 5 app. Created EF6 model using the database first approach which yielded the model as expected. Subsequently I will make changes in the database objects (tables, views, stored procs). When I go into the model to update it, the visible model will get updated. Looking at the Model Browser, I have to manually clean up the artifacts that no longer exist. Am I missing something in my procedure?
When you right click and update the model from the database, it will typically add new pieces automatically, but in my experience it doesn't automatically remove pieces that are no longer there, so you'll need to watch for those and delete them manually.
On the plus side, if you had any special customizations around a field (e.g. enum types), and the field gets renamed, this gives you a chance to compare the two configurations and make sure they line up before you delete the old field from your model.
I have a changefeed that works fine until I use the pluck() projection. If I use pluck, it doesn't pick up changes form inserts and deletes in my followers embedded collection.
r.table('users')
.getAll(name, {index: 'followers'})
//.without('password', 'phone')
.pluck('name', 'online') // using pluck doesn't pick up changes in insert/delete from followers
.changes({includeInitial:true});
I could use the without command but that seems more error prone as I would have to keep updating that list anytime I added fields to the user object.
Updates to user's online property gets picked up in the changefeed in either scenario.
Why does pluck not show changes to the followers set/collection property?
I'm not 100% sure, but I think this is because when you add the .pluck('name', 'online') to the end, and then you update the followers array, the changefeed logic applies the pluck and then compares the old value to the new value, and since neither of the plucked fields changed it decides that it's a "trivial" change and drops it. (In general ignoring trivial changes is what you want, since one of the main goals of .pluck.changes is to only be notified when the specified fields change.)
I think this probably isn't the desired behavior, though: it's probably more useful to only drop trivial changes if they don't cause the row to enter or exit the subscribed range. I opened https://github.com/rethinkdb/rethinkdb/issues/5205 to track that change.
This isn't supported right now. Check this ticket and this.
I'm curious what the difference is between overriding a table's modifiedField method versus overriding the update method.
In our case, we are working on switching the field datatype on a table. Since we cannot just change the data type of the field, we make a second field, and copy the information from the first into the second. Eventually, we update all the UI elements (forms and reports namely) to point to the new field, and then remove the old field. To help with copying the information from one field to another, we have been overriding the update method on the table to copy the value from the first field to the second.
I know this would probably be easier to maintain using the modifiedField method, but I'm curious if there are any significant differences (performance, missed updates, etc) by using the update method instead.
The main difference is that the code in modifiedField method is executed without writing into the Database. This way you can change the value of field2, but if a user close the form without saving the record then no updates will be in the DB. While using an update method you certainly write the changes.
I have an custom entity which needs to have a case number for an XRM Application, can I generate a case number from the Service -> Case.
If this is not possible, how can I do this with a plugin, I've looked at the crmnumbering.codeplex.com but this doesn't support 2011, anybody outthere have a solution or should I rewrite it myself?
thanks
I've ran into this same type of issue (I need a custom # for an entity). Here's how you can do it:
Create an Entity called "Counter"
Add a field called "new_customnumber", make it a string or a number depending on what you want
Create a new record for that entity with whatever you want in the new_customnumber field (let's say "10000")
Create a plugin (EntityNumberGenerator) that goes out and grabs that record (you'll probably want to set the security on this record/entity really tight so no one can mess with the numbers)
On Create of the "custom entity" fire the plugin. Grab the value in new_customnumber save it to the "custom entity" (let's say in a "case" field) increment the new_customnumber and save it to the Counter entity.
Warning, I'm not sure how this is with concurrency. Meaning I'm not sure if 2 custom entities being created at the same time can grab the same number (I haven't ran into an issue yet). I haven't figured out a way to "lock" a field I've retrieved in a plugin (I'm not sure it's possible).
You will be unable to create a custom number for custom entities from the normal area you set a case number.
Look at the CRM2011sdk\sdk\samplecode\cs\plug-ins\accountnumberplugin.cs plugin. It's really similar to what you want.
Ry
I haven't seen one for 2011 yet. Probably easiest to write it yourself.
I've always created a database with a table with a single column which is an IDENTITY column. Write an SP to insert, save the IDENTITY value to a variable, and DELETE the row all within a transaction. Return the variable. Makes for a quick and easy plug-in and this takes care of any concurrency issues.
The performance is fast and the impact to your SQL server is minimal.