如何在Mongo中描述收藏? [英] How do I describe a collection in Mongo?

查看:99
本文介绍了如何在Mongo中描述收藏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这是学习Mongo Db的第3天.我来自MySql宇宙...

So this is Day 3 of learning Mongo Db. I'm coming from the MySql universe...

很多时候,当我需要为我不熟悉的MySql表编写查询时,我会使用"desc"命令-基本上告诉我应该在查询中包括哪些字段.

A lot of times when I need to write a query for a MySql table I'm unfamiliar with, I would use the "desc" command - basically telling me what fields I should include in my query.

对于Mongo数据库,我该怎么做?我知道,我知道...我正在无模式数据库中搜索模式. =)但是用户还会如何知道在查询中使用哪些字段?

How would I do that for a Mongo db? I know, I know...I'm searching for a schema in a schema-less database. =) But how else would users know what fields to use in their queries?

我走错路了吗?显然,我正在尝试使用MySql在Mongo数据库中做事. Mongo的方式是什么?

Am I going at this the wrong way? Obviously I'm trying to use a MySql way of doing things in a Mongo db. What's the Mongo way?

推荐答案

在编辑器/mongoshell中键入以下查询

Type the below query in editor / mongoshell

var col_list= db.emp.findOne();
for (var col in col_list) { print (col) ; }

输出将为您提供集合中的列名称:

output will give you name of columns in collection :

_id
name
salary

这篇关于如何在Mongo中描述收藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆