mongodb - 有没有办法让mongo的返回值不带KEY?
PHPz
PHPz 2017-05-02 09:23:20
0
3
743

因为是用python开发的,只要获取一个集合中的某个字段,希望可以组成列表形式返回
比如下面数据,只要返回一个invitee的值组成的列表,而不要 "invitee" 这个KEY ,请教大神有没有办法的?

[{
    "_id" : ObjectId("583eda3c3a5ef82f08a5dbb3"),
    "quit" : false,
    "groupUin" : {
        "UserName" : "@@06d369ee17281c6df1da107f377a06898e91be8965e0d51f1876273484c0a685",
        "City" : "",
        "DisplayName" : "",
        "UniFriend" : 0,
        "MemberList" : [],
        "PYQuanPin" : "qunhaoquerenqun1",
        "RemarkPYInitial" : "",
        "Uin" : "8048117905@chatroom",
        "AppAccountFlag" : 0,
        "VerifyFlag" : 0,
        "Province" : "",
        "KeyWord" : "",
        "RemarkName" : "",
        "self" : {
            "UserName" : "@154290f91854836376af5345be69693f93fdec64a20a0b8bcdfff5d4b8a171b4",
            "RemarkPYQuanPin" : "",
            "DisplayName" : "暖暖的o",
            "KeyWord" : "",
            "PYInitial" : "",
            "Uin" : 1589615073,
            "RemarkPYInitial" : "",
            "PYQuanPin" : "",
            "MemberStatus" : 0,
            "NickName" : "暖暖的",
            "AttrStatus" : 16781349
        },
        "ChatRoomId" : 0,
        "isAdmin" : true,
        "ContactType" : 0,
        "HideInputBarFlag" : 0,
        "EncryChatRoomId" : "@fd153ce3dad59c8464de5b670c98b3a7",
        "AttrStatus" : 0,
        "Statues" : 1,
        "SnsFlag" : 0,
        "MemberCount" : 2,
        "OwnerUin" : 1589615073,
        "Alias" : "",
        "Signature" : "",
        "ContactFlag" : 2,
        "NickName" : "群号确认群1",
        "ChatRoomOwner" : "@154290f91854836376af5345be69693f93fdec64a20a0b8bcdfff5d4b8a171b4",
        "RemarkPYQuanPin" : "",
        "HeadImgUrl" : "/cgi-bin/mmwebwx-bin/webwxgetheadimg?seq=0&username=@@06d369ee17281c6df1da107f377a06898e91be8965e0d51f1876273484c0a685&skey=",
        "Sex" : 0,
        "StarFriend" : 0,
        "PYInitial" : "QHQRQ1",
        "HeadImgUpdateFlag" : 1
    },
    "inviter" : {
        "UserName" : "@154290f91854836376af5345be69693f93fdec64a20a0b8bcdfff5d4b8a171b4",
        "RemarkPYQuanPin" : "",
        "DisplayName" : "暖暖的o",
        "KeyWord" : "",
        "PYInitial" : "",
        "Uin" : 1589615073,
        "RemarkPYInitial" : "",
        "PYQuanPin" : "",
        "MemberStatus" : 0,
        "NickName" : "暖暖的",
        "AttrStatus" : 16781349
    },
    "invitee" : {
        "UserName" : "@1c5afebc224895d6a84711ebd8e4f8dc",
        "RemarkPYQuanPin" : "",
        "DisplayName" : "",
        "KeyWord" : "iss",
        "PYInitial" : "",
        "Uin" : 12266535,
        "RemarkPYInitial" : "",
        "PYQuanPin" : "",
        "MemberStatus" : 0,
        "NickName" : "admin",
        "AttrStatus" : NumberLong(2181050407)
    },
    "addScore" : 0,
    "invitTime" : 1480514108167.0
},{
    "_id" : ObjectId("583eda3c3a5ef82f08a5dbb3"),
    "quit" : false,
    "groupUin" : {
        "UserName" : "@@06d369ee17281c6df1da107f377a06898e91be8965e0d51f1876273484c0a685",
        "City" : "",
        "DisplayName" : "",
        "UniFriend" : 0,
        "MemberList" : [],
        "PYQuanPin" : "qunhaoquerenqun1",
        "RemarkPYInitial" : "",
        "Uin" : "8048117905@chatroom",
        "AppAccountFlag" : 0,
        "VerifyFlag" : 0,
        "Province" : "",
        "KeyWord" : "",
        "RemarkName" : "",
        "self" : {
            "UserName" : "@154290f91854836376af5345be69693f93fdec64a20a0b8bcdfff5d4b8a171b4",
            "RemarkPYQuanPin" : "",
            "DisplayName" : "暖暖的o",
            "KeyWord" : "",
            "PYInitial" : "",
            "Uin" : 1589615073,
            "RemarkPYInitial" : "",
            "PYQuanPin" : "",
            "MemberStatus" : 0,
            "NickName" : "暖暖的",
            "AttrStatus" : 16781349
        },
        "ChatRoomId" : 0,
        "isAdmin" : true,
        "ContactType" : 0,
        "HideInputBarFlag" : 0,
        "EncryChatRoomId" : "@fd153ce3dad59c8464de5b670c98b3a7",
        "AttrStatus" : 0,
        "Statues" : 1,
        "SnsFlag" : 0,
        "MemberCount" : 2,
        "OwnerUin" : 1589615073,
        "Alias" : "",
        "Signature" : "",
        "ContactFlag" : 2,
        "NickName" : "群号确认群1",
        "ChatRoomOwner" : "@154290f91854836376af5345be69693f93fdec64a20a0b8bcdfff5d4b8a171b4",
        "RemarkPYQuanPin" : "",
        "HeadImgUrl" : "/cgi-bin/mmwebwx-bin/webwxgetheadimg?seq=0&username=@@06d369ee17281c6df1da107f377a06898e91be8965e0d51f1876273484c0a685&skey=",
        "Sex" : 0,
        "StarFriend" : 0,
        "PYInitial" : "QHQRQ1",
        "HeadImgUpdateFlag" : 1
    },
    "inviter" : {
        "UserName" : "@154290f91854836376af5345be69693f93fdec64a20a0b8bcdfff5d4b8a171b4",
        "RemarkPYQuanPin" : "",
        "DisplayName" : "暖暖的o",
        "KeyWord" : "",
        "PYInitial" : "",
        "Uin" : 1589615073,
        "RemarkPYInitial" : "",
        "PYQuanPin" : "",
        "MemberStatus" : 0,
        "NickName" : "暖暖的",
        "AttrStatus" : 16781349
    },
    "invitee" : {
        "UserName" : "@1c5afebc224895d6a84711ebd8e4f8dc",
        "RemarkPYQuanPin" : "",
        "DisplayName" : "",
        "KeyWord" : "iss",
        "PYInitial" : "",
        "Uin" : 12266535,
        "RemarkPYInitial" : "",
        "PYQuanPin" : "",
        "MemberStatus" : 0,
        "NickName" : "admin",
        "AttrStatus" : NumberLong(2181050407)
    },
    "addScore" : 0,
    "invitTime" : 1480514108167.0
},{
    "_id" : ObjectId("583eda3c3a5ef82f08a5dbb3"),
    "quit" : false,
    "groupUin" : {
        "UserName" : "@@06d369ee17281c6df1da107f377a06898e91be8965e0d51f1876273484c0a685",
        "City" : "",
        "DisplayName" : "",
        "UniFriend" : 0,
        "MemberList" : [],
        "PYQuanPin" : "qunhaoquerenqun1",
        "RemarkPYInitial" : "",
        "Uin" : "8048117905@chatroom",
        "AppAccountFlag" : 0,
        "VerifyFlag" : 0,
        "Province" : "",
        "KeyWord" : "",
        "RemarkName" : "",
        "self" : {
            "UserName" : "@154290f91854836376af5345be69693f93fdec64a20a0b8bcdfff5d4b8a171b4",
            "RemarkPYQuanPin" : "",
            "DisplayName" : "暖暖的o",
            "KeyWord" : "",
            "PYInitial" : "",
            "Uin" : 1589615073,
            "RemarkPYInitial" : "",
            "PYQuanPin" : "",
            "MemberStatus" : 0,
            "NickName" : "暖暖的",
            "AttrStatus" : 16781349
        },
        "ChatRoomId" : 0,
        "isAdmin" : true,
        "ContactType" : 0,
        "HideInputBarFlag" : 0,
        "EncryChatRoomId" : "@fd153ce3dad59c8464de5b670c98b3a7",
        "AttrStatus" : 0,
        "Statues" : 1,
        "SnsFlag" : 0,
        "MemberCount" : 2,
        "OwnerUin" : 1589615073,
        "Alias" : "",
        "Signature" : "",
        "ContactFlag" : 2,
        "NickName" : "群号确认群1",
        "ChatRoomOwner" : "@154290f91854836376af5345be69693f93fdec64a20a0b8bcdfff5d4b8a171b4",
        "RemarkPYQuanPin" : "",
        "HeadImgUrl" : "/cgi-bin/mmwebwx-bin/webwxgetheadimg?seq=0&username=@@06d369ee17281c6df1da107f377a06898e91be8965e0d51f1876273484c0a685&skey=",
        "Sex" : 0,
        "StarFriend" : 0,
        "PYInitial" : "QHQRQ1",
        "HeadImgUpdateFlag" : 1
    },
    "inviter" : {
        "UserName" : "@154290f91854836376af5345be69693f93fdec64a20a0b8bcdfff5d4b8a171b4",
        "RemarkPYQuanPin" : "",
        "DisplayName" : "暖暖的o",
        "KeyWord" : "",
        "PYInitial" : "",
        "Uin" : 1589615073,
        "RemarkPYInitial" : "",
        "PYQuanPin" : "",
        "MemberStatus" : 0,
        "NickName" : "暖暖的",
        "AttrStatus" : 16781349
    },
    "invitee" : {
        "UserName" : "@1c5afebc224895d6a84711ebd8e4f8dc",
        "RemarkPYQuanPin" : "",
        "DisplayName" : "",
        "KeyWord" : "iss",
        "PYInitial" : "",
        "Uin" : 12266535,
        "RemarkPYInitial" : "",
        "PYQuanPin" : "",
        "MemberStatus" : 0,
        "NickName" : "admin",
        "AttrStatus" : NumberLong(2181050407)
    },
    "addScore" : 0,
    "invitTime" : 1480514108167.0
},]
PHPz
PHPz

学习是最好的投资!

모든 응답(3)
Peter_Zhu

해당 객체를 필터링합니다. xxxx.find({},{xxx:0},callback)

滿天的星座

이 기성 명령은 수행할 수 없는 것 같습니다. 키가 아닌 값만 반환합니다. js를 직접 작성하지 않는 한

左手右手慢动作

그냥 값을 반환하는 것은 불가능한 것 같습니다. db.collection.find({},{"invitee":1})를 사용하고, 반환한 후 코드에서 간단히 처리하면 됩니다.

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿