当前位置: 首页 > news >正文

网站开发费待摊年限人被备案了会有什么后果

网站开发费待摊年限,人被备案了会有什么后果,字体设计免费版在线立即生成,wordpress幻灯片主题设置MongoDB简介 MongoDB是一个开源的、文档型的NoSQL数据库程序。MongoDB将数据存储在类似JSON的文档中#xff0c;操作起来更灵活方便。NoSQL数据库中的文档(documents)对应于SQL数据库中的一行。将一组文档组合在一起称为集合(collections)#xff0c;它大致相当于关系数据库中…MongoDB简介 MongoDB是一个开源的、文档型的NoSQL数据库程序。MongoDB将数据存储在类似JSON的文档中操作起来更灵活方便。NoSQL数据库中的文档(documents)对应于SQL数据库中的一行。将一组文档组合在一起称为集合(collections)它大致相当于关系数据库中的表。 除了作为一个NoSQL数据库MongoDB还有一些自己的特性 易于安装和设置使用BSON(类似于JSON的格式)来存储数据将文档对象映射到应用程序代码很容易具有高度可伸缩性和可用性并支持开箱即用无需事先定义结构支持MapReduce操作将大量数据压缩为有用的聚合结果免费且开源......连接MongoDB 在Node.js中通常使用Mongoose库对MongoDB进行操作。Mongoose是一个MongoDB对象建模工具设计用于在异步环境中工作。 const mongoose require(mongoose);mongoose.connect(mongodb://localhost/playground).then(() console.log(Connected to MongoDB...)).catch( err console.error(Could not connect to MongoDB... , err)); Schema Mongoose中的一切都始于一个模式。每个模式都映射到一个MongoDB集合并定义该集合中文档的形状。 const courseSchema new mongoose.Schema({name: String,author: String,tags: [String],date: {type: Date, default: Date.now},isPublished: Boolean }); Model 模型是根据模式定义编译的构造函数,模型的实例称为文档,模型负责从底层MongoDB数据库创建和读取文档。 const Course mongoose.model(Course, courseSchema); const course new Course({name: Nodejs Course,author: Hiram,tags: [node, backend],isPublished: true }); 新增保存一个文档 async function createCourse(){const course new Course({name: Nodejs Course,author: Hiram,tags: [node, backend],isPublished: true});const result await course.save();console.log(result); }createCourse(); 查找文档 async function getCourses(){const courses await Course.find({author: Hiram, isPublished: true}).limit(10).sort({name: 1}).select({name: 1, tags:1});console.log(courses); } getCourses(); 使用比较操作符 async function getCourses(){const courses await Course// .find({author: Hiram, isPublished: true})// .find({ price: {$gt: 10, $lte: 20} }).find({price: {$in: [10, 15, 20]} }).limit(10).sort({name: 1}).select({name: 1, tags:1});console.log(courses); } getCourses(); 使用逻辑操作符 or (或) 只要满足任意条件and (与) 所有条件均需满足async function getCourses(){const courses await Course// .find({author: Hiram, isPublished: true}).find()// .or([{author: Hiram}, {isPublished: true}]).and([{author: Hiram, isPublished: true}]).limit(10).sort({name: 1}).select({name: 1, tags:1});console.log(courses); } getCourses(); 使用正则表达式 async function getCourses(){const courses await Course// .find({author: Hiram, isPublished: true})//author字段以“Hiram”开头// .find({author: /^Hiram/})//author字段以“Pierce”结尾// .find({author: /Pierce$/i })//author字段包含“Hiram”.find({author: /.*Hiram.*/i }).limit(10).sort({name: 1}).select({name: 1, tags:1});console.log(courses); } getCourses(); 使用count()计数 async function getCourses(){const courses await Course.find({author: Hiram, isPublished: true}).count();console.log(courses); } getCourses(); 使用分页技术 通过结合使用 skip() 及 limit() 可以做到分页查询的效果 async function getCourses(){const pageNumber 2;const pageSize 10;const courses await Course.find({author: Hiram, isPublished: true}).skip((pageNumber - 1) * pageSize).limit(pageSize).sort({name: 1}).select({name: 1, tags: 1});console.log(courses); } getCourses(); 更新文档 先查找后更新 async function updateCourse(id){const course await Course.findById(id);if(!course) return;course.isPublished true;course.author Another Author;const result await course.save();console.log(result); } 直接更新 async function updateCourse(id){const course await Course.findByIdAndUpdate(id, {$set: {author: Jack,isPublished: false}}, {new: true}); //true返回修改后的文档false返回修改前的文档console.log(course); } MongoDB更新操作符请参考https://docs.mongodb.com/manual/reference/operator/update/ 删除文档 deleteOne 删除一个deleteMany 删除多个findByIdAndRemove 根据ObjectID删除指定文档async function removeCourse(id){// const result await Course.deleteMany({ _id: id});const course await Course.findByIdAndRemove(id);console.log(course) } 转载于:https://www.cnblogs.com/hiramP/p/10724945.html
http://www.pierceye.com/news/69693/

相关文章:

  • 网站备案ip地址十大免费网站推广平台
  • 网站的注册和登录怎么做深圳网站制作厂家
  • 黄页网站推广效果怎么样实用的wordpress插件
  • 网站建设与管理感想滨州 网站开发
  • jsp做的当当网站的文档网站程序开发教程
  • 定制类做网站多少钱wordpress标签云不显示图片
  • 新泰市建设局网站四川建设厅官网查询
  • 什么程序做网站在哪里找软件开发公司
  • 网站制作思路做外贸网站格式
  • 网站建设中企动力推荐wordpress index 漏洞
  • 企业网站优化服务商中国建筑第八工程局招聘信息
  • 网站打开wordpresswordpress小程序 标签
  • 如何更改公司网站内容驻马店网络
  • ftp修改网站稿定设计在线ps
  • 珠海网站制作公简单大气的网站
  • 管理系统中的计算机应用在线看seo网站
  • 唐山地区网站开发公司ssh网站开发的书籍
  • 怎么看网站做没做优化湘潭网站建设哪些公司
  • 网站空间商查询公司网站建设技术方案
  • 做美图网站有哪些东西吗网页截图快捷键ctrl加什么
  • 深圳网站建设公司wordpress主题 kratos
  • 网站无法做301重定向深圳网站营销seo电话
  • 广东两学一做网站网站备案变更 能让首页关闭 二级域名继续
  • 电子产品网站开发背景廉洁文化网站建设方案
  • 网站建设近义词广州建站服务
  • 做网站怎样赚卖流量有效推广网站
  • 网站建设进程方案开公司一年需要多少费用
  • 做海报找图片的网站怎样建立自己手机网站
  • 手机网站导航按钮课桌公司网站建设
  • 音乐网站开发思路开发公司与子公司合作协议