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

做包子网站彩票网站开发制作

做包子网站,彩票网站开发制作,中山外贸网站建设公司,新类型网站在 Nest.js 中执行 SQL 查询通常涉及使用 TypeORM 或 Sequelize 这样的 ORM#xff08;对象-关系映射#xff09;库。这些库使得在 Nest.js 应用程序中连接和操作 SQL 数据库变得更加简单和直观。 以下是一个使用 TypeORM 在 Nest.js 中执行 SQL 查询的示例代码#xff1a;…在 Nest.js 中执行 SQL 查询通常涉及使用 TypeORM 或 Sequelize 这样的 ORM对象-关系映射库。这些库使得在 Nest.js 应用程序中连接和操作 SQL 数据库变得更加简单和直观。 以下是一个使用 TypeORM 在 Nest.js 中执行 SQL 查询的示例代码 首先确保你已经在项目中安装了 TypeORM 在user模块中的entites中user.entity.ts中有如下代码 import { Column, Entity, PrimaryGeneratedColumn } from typeorm; Entity() export class User {PrimaryGeneratedColumn()id: numberColumn()username: stringColumn()password: string }在user模块中的service中user.service.ts中有如下代码 import { Injectable } from nestjs/common; import { UserDto } from ./dto/create-user.dto; import { InjectRepository } from nestjs/typeorm; import { User } from ./entities/user.entity; import { Repository } from typeorm; Injectable() export class UserService {constructor(InjectRepository(User) private readonly user: RepositoryUser) { }async login(userDto: UserDto) {const userInfo await this.user.findOne({where: {username: userDto.username,password: userDto.password,},})return userInfo;}async register(userDto: UserDto) {const existingUser await this.user.findOne({where: {username: userDto.username,},});if (existingUser) {return 用户名已存在;}const data new User();data.username userDto.username;data.password userDto.password;return this.user.save(data);} }很明显没有使用sql语句但是也完成了sql操作 在另一个项目中使用的是 user模块中的user.model.ts中代码如下 import { Column, Model, Table } from sequelize-typescript;Table export class User extends ModelUser {Columnusername: string;Columnpassword: string;Columnavatar: string; } 在user.service.ts中代码如下 import { Injectable } from nestjs/common; import { CreateUserDto } from ./dto/create-user.dto; import { InjectModel } from nestjs/sequelize; import { User } from ./model/user.model; Injectable() export class UserService {constructor(InjectModel(User) private userModel: typeof User,) {}async create(createUserDto: CreateUserDto) {let res await this.userModel.build({...createUserDto})await res.save()return res}async findAll() {let res await this.userModel.findAll()return res}async find(createUserDto: CreateUserDto) {let res await this.userModel.findOne({where: {...createUserDto}})return res}async findOne(username: string) {let res await this.userModel.findOne({where: {username}})return res ! null ? res : null}async uploadAvatar(username: string, avatar: string) {let res await this.userModel.update({avatar}, {where: {username: username}})return {code: 200,msg: 上传成功,data: res}}async hasAvatar(username: string) {let res await this.userModel.findOne({where: {username: username}})return res.avatar ! null} }
文章转载自:
http://www.morning.bklkt.cn.gov.cn.bklkt.cn
http://www.morning.yhljc.cn.gov.cn.yhljc.cn
http://www.morning.tphjl.cn.gov.cn.tphjl.cn
http://www.morning.zdkzj.cn.gov.cn.zdkzj.cn
http://www.morning.xxrgt.cn.gov.cn.xxrgt.cn
http://www.morning.kngx.cn.gov.cn.kngx.cn
http://www.morning.rbjf.cn.gov.cn.rbjf.cn
http://www.morning.mkxxk.cn.gov.cn.mkxxk.cn
http://www.morning.nflpk.cn.gov.cn.nflpk.cn
http://www.morning.jwdys.cn.gov.cn.jwdys.cn
http://www.morning.zlbjx.cn.gov.cn.zlbjx.cn
http://www.morning.srckl.cn.gov.cn.srckl.cn
http://www.morning.fqnql.cn.gov.cn.fqnql.cn
http://www.morning.dwgcx.cn.gov.cn.dwgcx.cn
http://www.morning.qwdqq.cn.gov.cn.qwdqq.cn
http://www.morning.lkkgq.cn.gov.cn.lkkgq.cn
http://www.morning.bhpjc.cn.gov.cn.bhpjc.cn
http://www.morning.ggnkt.cn.gov.cn.ggnkt.cn
http://www.morning.fglxh.cn.gov.cn.fglxh.cn
http://www.morning.tyjnr.cn.gov.cn.tyjnr.cn
http://www.morning.gbtty.cn.gov.cn.gbtty.cn
http://www.morning.mqdr.cn.gov.cn.mqdr.cn
http://www.morning.xinyishufa.cn.gov.cn.xinyishufa.cn
http://www.morning.jcffp.cn.gov.cn.jcffp.cn
http://www.morning.mjjty.cn.gov.cn.mjjty.cn
http://www.morning.qdzqf.cn.gov.cn.qdzqf.cn
http://www.morning.wypyl.cn.gov.cn.wypyl.cn
http://www.morning.mdpkf.cn.gov.cn.mdpkf.cn
http://www.morning.lhgqc.cn.gov.cn.lhgqc.cn
http://www.morning.zxqxx.cn.gov.cn.zxqxx.cn
http://www.morning.hfyll.cn.gov.cn.hfyll.cn
http://www.morning.hqwcd.cn.gov.cn.hqwcd.cn
http://www.morning.mjbjq.cn.gov.cn.mjbjq.cn
http://www.morning.gchqy.cn.gov.cn.gchqy.cn
http://www.morning.yrmpr.cn.gov.cn.yrmpr.cn
http://www.morning.phlwj.cn.gov.cn.phlwj.cn
http://www.morning.bgqr.cn.gov.cn.bgqr.cn
http://www.morning.tlrxt.cn.gov.cn.tlrxt.cn
http://www.morning.rxtxf.cn.gov.cn.rxtxf.cn
http://www.morning.dtrzw.cn.gov.cn.dtrzw.cn
http://www.morning.ydrfl.cn.gov.cn.ydrfl.cn
http://www.morning.zsleyuan.cn.gov.cn.zsleyuan.cn
http://www.morning.sqnrz.cn.gov.cn.sqnrz.cn
http://www.morning.bktzr.cn.gov.cn.bktzr.cn
http://www.morning.rhmt.cn.gov.cn.rhmt.cn
http://www.morning.cfcpb.cn.gov.cn.cfcpb.cn
http://www.morning.zmlnp.cn.gov.cn.zmlnp.cn
http://www.morning.xcdph.cn.gov.cn.xcdph.cn
http://www.morning.jwdys.cn.gov.cn.jwdys.cn
http://www.morning.zfrs.cn.gov.cn.zfrs.cn
http://www.morning.zshuhd015.cn.gov.cn.zshuhd015.cn
http://www.morning.drcnn.cn.gov.cn.drcnn.cn
http://www.morning.xwrhk.cn.gov.cn.xwrhk.cn
http://www.morning.mlcwl.cn.gov.cn.mlcwl.cn
http://www.morning.ykrg.cn.gov.cn.ykrg.cn
http://www.morning.yxnfd.cn.gov.cn.yxnfd.cn
http://www.morning.lonlie.com.gov.cn.lonlie.com
http://www.morning.dnhdp.cn.gov.cn.dnhdp.cn
http://www.morning.rqwmt.cn.gov.cn.rqwmt.cn
http://www.morning.incmt.com.gov.cn.incmt.com
http://www.morning.brtxg.cn.gov.cn.brtxg.cn
http://www.morning.hwprz.cn.gov.cn.hwprz.cn
http://www.morning.qsy39.cn.gov.cn.qsy39.cn
http://www.morning.kztpn.cn.gov.cn.kztpn.cn
http://www.morning.mmxt.cn.gov.cn.mmxt.cn
http://www.morning.qnzpg.cn.gov.cn.qnzpg.cn
http://www.morning.lgphx.cn.gov.cn.lgphx.cn
http://www.morning.nmkfy.cn.gov.cn.nmkfy.cn
http://www.morning.npbgj.cn.gov.cn.npbgj.cn
http://www.morning.bchhr.cn.gov.cn.bchhr.cn
http://www.morning.qmnjn.cn.gov.cn.qmnjn.cn
http://www.morning.mtjwp.cn.gov.cn.mtjwp.cn
http://www.morning.bqfpm.cn.gov.cn.bqfpm.cn
http://www.morning.wsjnr.cn.gov.cn.wsjnr.cn
http://www.morning.qqbjt.cn.gov.cn.qqbjt.cn
http://www.morning.mhfbf.cn.gov.cn.mhfbf.cn
http://www.morning.xgchm.cn.gov.cn.xgchm.cn
http://www.morning.msmtf.cn.gov.cn.msmtf.cn
http://www.morning.gjqgz.cn.gov.cn.gjqgz.cn
http://www.morning.jwrcz.cn.gov.cn.jwrcz.cn
http://www.tj-hxxt.cn/news/259985.html

相关文章:

  • 网站制作培训wordpress主题 m1
  • 木材模板.网站网站建设华为
  • 赤峰做企业网站公司购物网站每个模块主要功能
  • 网站建设需要懂什么语言上国外的网站很慢
  • 网站首页动图怎么做营销师
  • 网站建设图片怎么调高端网站建设过程
  • 中国建设银行理财网站宣威做网站建设的公司
  • 网页制作公司 软件周口seo公司
  • 重庆网站推广免费软件wordpress主题设计师导航
  • ja.wordpress.org漳州seo网站快速排名
  • 学校网站建设学生文明上网网站开发 cms
  • 花店网站模板小程序开发费用多少
  • 如何用模板搭建网站询盘网站
  • 国外电商网站如何建立温州专业营销网站制作
  • 登封市建设局网站欧美风格网站模版
  • 住房及城乡建设部网站九大员网站网页直播怎么做的
  • 西安比较好的网络公司专业网站优化培训
  • 旅游网站设计与分析程序员培训机构有哪些
  • 集团网站建设方案广告传媒公司营业执照经营范围
  • 可信网站代码网站注册界面
  • 开发网站培训班wordpress 升级 无法创建目录
  • 企业网站建设与实施调研报告基本情况常熟网络推广
  • 商务网站建设定义赣州百度
  • 网页设计项目报告总结整站优化全网营销
  • 国家森林公园网站建设做的比较好的网站推荐
  • 做俄语网站龙华网站建设yihekj
  • 怎么建设信息网站网站制作易捷网络
  • 厦门网站制作软件建设公司网站的请示
  • 北京微网站建设公司推荐国外网站设计
  • 网站开发招标技术要求如何微信支付购物网站