Example of webpack4+express+mongodb+vue implementing addition, deletion, modification and query

Before explaining, let’s take a look at the effect as follows: 1) The effect of the entire page is as follows: 2) The effect of adding new data is as follows: 3) The new addition is successful as follows: 4) The effect of editing data is as follows: 5) The result of successful editing is as follows: 6) The effect of deleting data is as follows: 7) The effect of successful deletion is as follows: 8) The query results are as follows: With the above effect, we will still do the same as before. Let’s first look at the structure of our entire project as follows: ### The directory structure is as follows: demo1 # project name | |— dist # Directory file generated after packaging | |— node_modules # All dependent packages | |—-database # Database related file directory | | |—db.js # Database connection operation of mongoose class library | | |—user.js # Schema Create model | | |—addAndDelete.js # Add, delete, modify and check operations | |— app | | |—index | | | |– views # Store all vue page files | | | | |– list.vue # List data | | | | |– index.vue…

Simple method to operate MongoDB with PHP (installation, addition, deletion, modification and query)

The examples in this article describe how to simply operate MongoDB with PHP. Share it with everyone for your reference, the details are as follows: If PHP operates MongoDB, first download the MongoDB expansion package from the Internet, https://github.com/mongodb/mongo-php-driver/downloads, and select the corresponding expansion package. I downloaded this and decompressed it. VC6 is suitable for apache, VC9 is suitable for IIS, and ts (thread safe) means that PHP runs in the form of a module. Then put the php_mongo.dll in the ext folder in PHP, then add extension=php_mongo.dll to PHP.INI and restart apache. Now the PHP extension MongoDB package is installed. For information on querying some MongoDB functions, please refer to the manual http://us.php.net/manual/en/class.mongocollection.php PHPDataBase; $collection = $db->PHPCollection; /*——————————– * delete *——————————– $collection->remove(array(“name” => “xixi111”)); */ /*——————————— * insert *——————————– for($i = 0;$i “xixi”.$i,”email” => “673048143_”.$i.”@qq.com”,”age” => $i*1+20); $collection->insert($data); } */ /*———————————- * Find *——————————– $res = $collection->find(array(“age” => array(‘$gt’ => 25,’$lt’ => 40)),array(“name” => true)); foreach($res as $v) { print_r($v); } */ /*———————————- * renew *——————————– $collection->update(array(“age” =>22),array(‘$set’ => array(“name” => “demoxixi”))); */ ?> Readers who are interested in more PHP-related content can check out the special topics of this site: “Complete of PHP + MongoDB database operation skills”,…

Detailed explanation of Django’s restful usage (built-in addition, deletion, modification and query)

What is rest REST is an architectural design guideline that all web applications should abide by. Representational State Transfer, translated as “presentation layer state transformation”. Resource-oriented is the most obvious feature of REST, a set of different operations for the same resource. A resource is a nameable abstract concept on the server. Resources are organized with nouns as the core. The first thing to focus on is the nouns. REST requires that various operations on resources must be performed through a unified interface. Only a limited set of operations can be performed on each resource. GET is used to obtain resources, POST is used to create new resources (can also be used to update resources), PUT (PATCH) is used to update resources, and DELETE is used to delete resources. api definition specification http://xxx.com/api/ Resources In the RESTful architecture, each URL represents a resource, so the URL cannot have verbs, only nouns, and the nouns used often correspond to the table names of the database. Generally speaking, the tables in the database are “collections” of the same type of records, so the nouns in the API should also be pluralized. For example, if there is an API that provides zoo information,…

Java connects to Mongodb to implement addition, deletion, modification and query

The example in this article shares with you the specific code for connecting java to Mongodb to implement addition, deletion, modification and query for your reference. The specific content is as follows 1. Create a maven project org.mongodb mongodb-driver 3.4.1 2. Write code 1. Query all package com.czxy.mongodb; import com.alibaba.fastjson.JSON; import com.mongodb.*; import java.util.List; import java.util.Set; public class Find { public static void main(String[] args) { //Client link MongoClient mOngodbClint= new MongoClient(“localhost”, 27017); // Get all databases List databaseNames = mongodbClint.getDatabaseNames(); for (String databaseName : databaseNames) { System.out.println(“Database Name “+databaseName); } //Connect to the specified database DB db = mongodbClint.getDB(“text”); //Get all collection names under the current database Set collectiOnNames= db.getCollectionNames(); for (String dbname : collectionNames) { System.out.println(“Collection name “+dbname); } // Connect to the specified collection DBCollection collection = db.getCollection(“stus”); //Data collection information DBCursor dbObjects = collection.find(); while (dbObjects.hasNext()){ //Read data DBObject next = dbObjects.next(); // json format conversion Stus parse = JSON.parseObject(next.toString(), Stus.class); // data output System.out.println(parse); } } } 2. Add data package com.czxy.mongodb; import com.mongodb.MongoClient; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; import org.bson.Document; import java.util.HashMap; import java.util.Map; public class Insert { public static void main(String[] args) { // Get connection MongoClient mOngodbClint= new MongoClient(“localhost”, 27017); // Connect to…

Introduction to MongoDB, installation, additions, deletions and modifications

Introduction to MongoDB, installation, addition, deletion, modification and query

What the hell is MongoDB? Recently, too many students have mentioned MongoDB to me. They want to learn MongoDB, but they still don’t know what MongoDB is. In other words, they know it is a database or a file database, but they don’t know how to use it. That’s great, it’s said that it only comes out after a thousand calls, I’ll show it to you now: 1. First introduction to MongoDB: Everything must start with theory, don’t you think? MongoDB is a database based on distributed file storage. Written in C++ language. Designed to provide scalable, high-performance data storage solutions for WEB applications. MongoDB is a product between a relational database and a non-relational database. It is the most feature-rich among non-relational databases and is most similar to a relational database. The official explanation is given above, so to sum up, Mader F U C K! There is too little effective information (completely useless) So let me tell you about MongoDB in human language The biggest difference between it and the relational database we use is the constraint. It can be said that there is almost no constraint in the file database. In theory, there are no primary and…

python3 django mysql addition, deletion, modification and query

python3djangomysql addition, deletion, modification and query

Use Python’s django framework to connect to the database and operate the database code: import logging from django.db import connection LOG = logging.getLogger(“boss”) def dictfetchall(cursor): “Return all rows from a cursor as a dict” desc = cursor.description if desc ==None: return [] columns = [col[0] for col in desc] # for row in cursor.fetchall(): # rows.append(row) return [ dict(zip(columns, row)) for row in cursor.fetchall() ] def dictfetone(cursor): desc = cursor.description if desc ==None: returnNone columns = [col[0] for col in desc] row = cursor.fetchone() if row ==None: returnNone return dict(zip(columns,row)) def fetchall(sql,params=[]): cursor =connection.cursor() cursor.execute(sql,params) ret = dictfetchall(cursor) return ret def fetchone(sql,params=[]): cursor =connection.cursor() cursor.execute(sql,params) ret = dictfetone(cursor) cursor.close() return ret def executeDb(sql,params=[]): cursor =connection.cursor() ret = cursor.execute(sql,params) cursor.close() return ret You can see in the code that after the cursor is executed, close is executed. I wonder if Diango’s mysql connection does not have a connection pool? With this question in mind, I checked online and found that there is indeed documentation in this regard. Later, when I looked at the official website, I found: The latest version of Django already includes connection pooling, which can be controlled by modifying the configuration. Official documentation: https://docs.djangoproject.com/en/1.9/ref/databases/ The best proof is…

Gin framework combined with gorm to implement mysql addition, deletion, modification and query

Gin framework combined with gorm to implement mysql addition, deletion, modification and query

1. Mysql connection in Gin framework Install the driver (no need to import it if you install go-gorm/mysql): go get github.com/go-sql-driver/mysql Install gorm: github.com address: go get github.com/go-gorm/gorm go get github.com/go-gorm/mysql Official address: go get gorm.io/gorm go get gorm.io/gorm go mod dependency configuration: go mod tidy Create database connection directories (dbtabases) as needed: mysql.go connection file: package databases import ( “fmt” “gorm.io/driver/mysql” “gorm.io/gorm” ) var Eloquent *gorm.DB func init() { var err error //Username: password@tcp (database ip or domain name: port)/database name?charset=database encoding&parseTime=True&loc=Local dsn := “root:root@tcp(127.0.0.1:3306)/gin_test?charset=utf8&parseTime=True&loc=Local” Eloquent, err = gorm.Open(mysql.Open(dsn), &gorm.Config{}) if err != nil { fmt.Printf(“mysql connect error %v”, err) } if Eloquent.Error != nil { fmt.Printf(“database error %v”, Eloquent.Error) } } main.go file: //SetMaxIdleConns is to set the maximum number of connections when idle //SetMaxOpenConns sets the maximum number of open connections to the database //SetConnMaxLifetime The life cycle and other information of each connection sqlDB, err := orm.Eloquent.DB() if err != nil { panic(err) } sqlDB.SetMaxIdleConns(5) sqlDB.SetMaxOpenConns(10) sqlDB.SetConnMaxLifetime(-1) //Delayed calling function defer sqlDB.Close() //Register route router := routers.RegisterRoutes() //The bound port is 8088 router.Run(“:8088”) 2. Example of adding, deleting, modifying and querying data tables: Create a test table: CREATE TABLE `tb_test` ( `id` int(10) unsigned NOT NULL…

Python’s Web framework, Django’s ORM, model basics, MySQL connection configuration and addition, deletion, modification and query

Introduction to ORM in Django ORM concept: Object Relational Mapping (ORM for short): Use an object-oriented approach to describe the database and operate the database. You can even add, delete, modify, and perform various operations on the database without writing SQL statements. We only need to be familiar with Python’s object-oriented approach to clearly understand the relationship between various data. Django model mapping relationship: Database connection configuration Django supports mainstream databases, all of which have configurations. You can configure them in the setting. Let’s take a look at how to configure MySQL. Description of db.sqlite3 file The db.sqlite3 file is also a database file. Django will configure this file by default. This file is very small and is used by many stand-alone and Internet users Django configuration process for connecting to mysql: Install pymysql for python to operate mysql database pip install pymysql To create a database user, a user with permission to create a database is required Create database #Enter the database, this command uses rootAccount. Normally, use the database account given by the database administrator >>>(django) pyvip@Vip:~$ mysql -uroot -pqwe123 #Create a database called crm >>>mysql> create database crm; Query OK, 1 row affected (0.00 sec) Modify setting…

Golang native sql operation Mysql database addition, deletion, modification and query

To operate the mysql database in Golang, you first need to configure GOPATH in the current system, because you need to use the go get command to download the driver package to GOPATH for use. First configure your GOPATH, execute the following command, Download and install the mysql driver. After the download is completed, it will be in the src/github.com directory under GOPATH go get -u github.com/go-sql-driver/mysql Then the local mysql service is started and a table is created as a test DROP TABLE IF EXISTS `student`; CREATE TABLE `student` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) CHARACTER SET latin1 NOT NULL DEFAULT ”, `age` tinyint(4) DEFAULT ‘0’, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; Connect mysql database command //mysql database, username: password @tcp connection: port 3306/test library?Character set utf8 db, err := sql.Open(“mysql”, “root:root@tcp (127.0.0.1:3306)/test?charset=utf8”) //Returns the connection character, and err Add, delete, modify and check code (import the mysql driver package and use the datebase/sql Open function to connect) package main import ( “database/sql” // This is an abstraction layer package, such as distinguishing between mysql, orcal and other databases. Only this package cannot connect to mysql, and it also needs to be matched with the…

MongoDB learning day02 database addition, deletion, modification and query

(window system, used in cmd command prompt) 1. Database usage Manage mongodb database: mongo Clear screen: cls View all databases: show dbs 2. Create database use student If you want to successfully create the database, you must insert data. The database cannot insert data, it can only insert data into the collection. db.user.insert({“name”:”zhangsan”}) db.user The system found that user is a strange collection, so it automatically created the collection. Show all collections in the current database show collections Delete collections db.user.drop() Delete database db.dropDatabase() 3. Add db.user.insert({“name”: “zhangsan”}) db.Collection name.insert({“name”:”zhangsan”}) 4. Delete db.user.remove({“name”:”zhangsan”}) db.collection name.remove({condition}) Remove all conditions p> db.user.remove({“name”:”zhangsan”},{justOne:true}) Delete the first item that meets the conditions 5. Change db.user.update({“name”:”zhangsan”},{$set{“age”:16}}) db.set name.update({condition},{$set{updated field value}}) Update the first piece of data that meets the conditions db.user.update( {“name”:”zhangsan”},{$set{“age”:16}},{multi:true}) Update all data that meets the conditions db. student.update({“name”:”Xiao Ming”},{“name”:”Da Ming”, “age”:16}) Note that without adding the $set keyword, it is a complete replacement. That is, replace the data matching the name Xiaoming with {“name”:”Daming”, “age”:16} db.users.update({name: ‘Lisi’}, {$inc: {age: 50}}, false, true)Equivalent to: update users set age = age + 50 where name = ‘Lisi’ db.users.update({name: ‘Lisi’ ‘}, {$inc: {age: 50}, $set: {name: ‘hoho’}}, false, true)Equivalent to: update users set age =…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索