How to take Backup from MongoDB and Restore to MongoDB
This will take backup of your passed database name, to the passed folder. It…
April 27, 2020
You already have a content type with one or more fields in it. Later, you realize you should rename it due to whatever reason. Lets take an example:
Drupal provides no way to rename existing fields of a content type. But, you can do this programatically or by a db query.
Do following steps:
$query = db_select( 'node', 'n' );
$query
->condition( 'n.type', 'article' )
->fields('n', array('nid'));
$result = $query
->execute()
->fetchAll();
foreach( $result as $row ) {
$nd = Drupal\node\Entity\Node::load($row->nid);
$nd->body = $nd->field_article_introduction;
$nd->field_image = $nd->field_top_image;
$nd->save();
}
The idea is to fetch all such nodes for that particular content type, and assign old values to the new fields you just created.
Clear the cache and test it.
This will take backup of your passed database name, to the passed folder. It…
Introduction In our previous post, where we saw How to configure comments module…
Problem In drupal textarea field, it was always a pain to see the two links…
I have a custom content type, and there are around 2000 number of nodes in my…
While running docker commands with some images, I started getting error: The…
Problem Statement I’ve been using image styles, and heavily used “Scale and crop…
In this post, we will see some of the frequently used concepts/vocabulary in…
System design interview is pretty common these days, specially if you are having…
Introduction You are given an array of integers with size N, and a number K…
Graph Topological Sorting This is a well known problem in graph world…
Problem Statement Given a Binary tree, print out nodes in level order traversal…
Problem Statement Given an array nums of n integers and an integer target, are…